
clear

************************************
* prepare database for original dataset (Cavari & Freedman 2018)
* all surveys downloaded from Roper iPoll as dat files.  
* once downloaded, set to your local directory and run. 
************************************
* import all questions
{
set more off
*** USPEW2004-01NII
{
infix 1 lines 1: weight 1321-1324  rid 1-6 sex 57 education 267/*
	*/ party 279 partyln 280 ideology 281 regist 277 age 265-266/*
	*/ q28_f 235 q31_f 240/*
	*/ race 269 hispanic 268/*
	*/ news_demnom 95 news_iraq 96 news_econ 97 news_terror 98 news_madcow 99/*
	*/ news_iran 100 news_libya 101 news_mars 102 /*
	*/ income 275-276 /*
	*/ using Pew/USPEW2004-01NII.dat

gen survey="USPEW2004-01NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q28_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q31_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

saveold SNR.dta, replace
}
*** USPEW2004-07FP
{
clear

use Pew/USPEW2004-07FP.dta, clear
rename educ education
rename ideo ideology
rename pvote00 vote
rename q25 q25_d
rename q26 q26_d
rename q32 q32_d
rename q34f1 q34_f
rename q36f2 q36_f
rename q37f1 q37_f
rename q45f1 q45_f
rename q46f2 q46_f
rename q47 q47_f
rename q48f1 q48_f
rename q52f2 q52_f
rename q54f1 q54_f
rename q60 q60_f
rename q61 q61_f
rename q62 q62_f
rename q64 q64_f
rename q72f1 q72_f
rename q73f2 q73_f
rename q77f2 q77_f
rename hisp hispanic

keep weight rid sex education party partyln ideology regist age/*
	*/ vote q25_d q26_d q32_d q34_f q36_f q37_f q45_f q46_f q47 q48_f/*
	*/ q52_f q54_f q60_f q62_f q64_f q72_f q73_f q77_f race hispanic/*
	*/ q3a q3b q3c q3d q3e q3f q3g q3h q3i income
	
rename (q3a q3b q3c q3d q3e q3f q3g q3h q3i) (news_elections news_iraq news_demnom news_sudan news_saddam news_fahrenheit news_iraqgov news_clinton news_gas)
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
gen survey="USPEW2004-07FP"	
gen pollmethod=1

local vars_1 q25_d q26_d q32_d q36_f q37_f q45_f q46_f q48_f q52_f q54_f q60_f q62_f q64_f q72_f q73_f q77_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q34_f q47_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-08NII
{
clear
infix 1 lines 1: weight 318-321 rid 1-6 sex 19 age 206-207 education 208/*
	*/ regist 219 party 221 partyln 223 ideology 224 vote 225 /*
	*/ q36_d 172 q37_d 173 q41_d 177 q51_f 184 q53_f 186 q55_f 188 q61_f 198 /*
	*/ race 210 hispanic 209 income 217-218 /*
	*/ using Pew/USPEW2004-08NII.dat

gen survey="USPEW2004-08NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)

local vars_1 q36_d q37_d q41_d q51_f q53_f q55_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q61_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-09EAR
{
clear
infix 1 lines 1: weight 210-213 rid 1-6 sex 21 regist 38 age 135-136/*
	*/ education 137 party 147 partyln 149 ideology 150 vote 151 /*
	*/ q28_f 117 q30_f 119 q32_f 121 q36a_d 125 q36b_d 126 q38_d 128 q39_f 129/*
	*/ race 139 hispanic 138/*
	*/ news_elections 23 news_iraq 24 news_econ 25 news_repconv 26 /*
	*/ news_olympics 27 news_hurricane 28 news_chechen 29 news_cads 30 /*
	*/ news_clinton 31 news_bush 32 income 145-146 /*
	*/ using Pew/USPEW2004-09EAR.dat

gen survey="USPEW2004-09EAR"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
recode q39_f (1/4 6=1) (5 9=0)
local vars_1 q28_f q30_f q32_f q36a_d q36b_d q38_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-09MID
{
clear
infix 1 lines 1: weight 105-108 rid 1-6 sex 20 regist 22 age 35-36/*
	*/ education 37 party 44 partyln 45 ideology 46/*
	*/ q10_f 29 q12_f 31/*
	*/ race 39 hispanic 38 income 42-43 /*
	*/ using Pew/USPEW2004-09MID.dat

gen survey="USPEW2004-09MID"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q10_f q12_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2004-10earpol
{
clear
infix 1 lines 1: weight 159-162 rid 1-8 sex 13 regist 15 age 108-109/*
	*/ education 110 party 120 partyln 121 ideology 122 vote 123/*
	*/ q23_f 104/*
	*/ race 112 hispanic 111 income 118-119 /*
	*/ using Pew/uspew2004-10earpol.dat

gen survey="uspew2004-10earpol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q23_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-10MIDPOL
{
clear
infix 1 lines 1: weight 1131-1134 rid 1-4 sex 68 regist 92 age 807-808/*
	*/ education 809 party 1074 partyln 1076 ideology 1077 vote 1078/*
	*/ q40_f 778 q42_f 780 q43_f 781 q44_f 782/*
	*/ race 811 hispanic 810 income 1072-1073 /*
	*/ using Pew/USPEW2004-10MIDPOL.dat

gen survey="USPEW2004-10MIDPOL"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q40_f q42_f q43_f q44_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-ELECWKND
{
clear
infix 1 lines 1: weight 195-198 rid 1-4 sex 16 regist 23-24 age 85-86/*
	*/ education 87-88 party 105-106 partyln 109-110 ideology 111-112/*
	*/ vote 113-114/*
	*/ q14_f 77-78 /*
	*/ race 91-92 hispanic 89-90 news_elections 19-20 /*
	*/ income 103-104 /*
	*/ using Pew/USPEW2004-ELECWKND.dat

gen survey="USPEW2004-ELECWKND"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q14_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-04NII
{
clear 
infix 1 lines 1: weight 103-106 rid 1-6 sex 56 regist 87 age 80-81/*
	*/ education 82 party 89 partyln 90 ideology 91/*
	*/ q4_f 70 q6_f 72 q9_f 77/*  // q9_f example where neither is a valid answer
	*/ race 84 hispanic 83 income 85-86 /*
	*/ using Pew/USPEW2004-04NII.dat

gen survey="USPEW2004-04NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q4_f q6_f q9_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-04LATE
{
clear 
infix 1 lines 1: weight 73-76 rid 1-6 sex 48 age 60-61/*
	*/ education 62 party 67 partyln 68 ideology 69/*
	*/ q3_f 54 q5_f 56/* 
	*/ race 64 hispanic 63 income 65-66 /*
	*/ using Pew/USPEW2004-04LATE.dat

* regist	
gen survey="USPEW2004-04LATE"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q3_f q5_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-06VOTE
{
clear 
use Pew/USPEW2004-06VOTE.dta

rename educ education
rename ideo ideology
rename hisp hispanic
rename pvote00 vote
rename q51 q51_f
rename q53 q53_f
rename q56 q56_f //example of volunteered valid answer

keep weight rid sex age education regist vote party partyln ideology/*
	*/ q51_f q53_f q56_f race hispanic income

* regist	
gen survey="USPEW2004-06VOTE"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q51_f q53_f q56_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2004-03NII
{
clear 
infix 1 lines 1: weight 1296-1299 rid 1-6 sex 57 age 243-244/*
	*/ education 245 regist 252 party 254 partyln 255 ideology 256 vote 257/*
	*/ q1_f 170 q3_f 172 q29_f 194 q30_f 195 q31a_f 201 q31b_f 202/*
	*/ q31c_f 203 q31d_f 204 q31e_f 205 q37_d 227 q38_d 228/*
	*/ race 247 hispanic 246 income 250-251/*
	*/ using Pew/USPEW2004-03NII.dat

gen survey="USPEW2004-03NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* q1_f = ir1 q3_f = ir3

local vars_1 q1_f q3_f q29_f q30_f q31a_f q31b_f q31c_f q31d_f q31e_f q37_d q38_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2004-ialsel
{
clear 
infix 1 lines 1: weight 20-23 rid 1-6 sex 25 age 191-192/*
	*/ education 195 party 202 ideology 203 regist 204/*
	*/ q23a_f 68 q23b_d 69 q23c_f 70 q23d_d 71 q23e_d 72/*
	*/ q1_f 104 q7a_f 113 q7b_f 115 q7c_f 117 q7d_f 119/*
	*/ q9b_f 123 q9d_f 127 q11_d 128 /*
	*/ q17a_d 137 q17b_d 139 q17c_d 141 q17d_d 143/*
	*/ q19a_d 145 q19b_d 147 q19c_d 149 q19d_d 151/*
	*/ q101_f 152 q107a_f 161 q107b_f 163 q107c_f 165 q107d_f 167/*
	*/ q109a_f 169 q109b_f 171 q109c_f 173 q109d_f 175/*
	*/ race 200 hispanic 199 news_elections 80 income 210 /*
	*/ using Pew/uspew2004-ialsel.dat

recode ideology (1=5) (2=4) (3=3) (4=2) (5=1) (9=9)	
recode race (1=1) (2=2) (3=3) (4/6=4) (9=9)
* q1_f = iraq1 | q7_f = iraq7 | q9_f = iraq9
* q11_d = gm1 | q17 = gm7 | q19 = gm9
* q101_f = ft1 q107 = ft7 | q109 = ft9
* vote partyln
gen survey="uspew2004-ialsel"	
gen pollmethod=1
recode income (1/2=1) (3=2) (4/5=3) (6=4) (7/8=5) (else=.)
local vars_1 q23a_f q23b_d q23c_f q23d_d q23e_d q1_f q11_d q101_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q7a_f q7b_f q7c_f q7d_f q9b_f q9d_f q17a_d q17b_d q17c_d q17d_d q19a_d q19b_d q19c_d q19d_d q107a_f q107b_f q107c_f q107d_f q109a_f q109b_f q109c_f q109d_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR.dta
rename vote vote2000
saveold SNR.dta, replace
}
*** USPEW2004-TYPO
{
clear 
infix 1 lines 1: weight 161-164 rid 1-8 sex 32 age 128-129/*
	*/ education 131 party 143 partyln 145 ideology 148 regist 141/*
	*/ vote2004 149 q11b_d 56 q11d_d 58 q11g_d 61 q11i_f 62/*
	*/ q20q_d 85 q20r_d 86 q20u_d 89 q20v_d 90 q20bb_f 95/*
	*/ q20cc_f 96 q20dd_d 97 q20ee_d 98 q20ff_d 99/*
	*/ q32_d 102 q34_d 104 /*
	*/ q36a_d 106 q36b_d 107 q36c_d 108 q36d_d 109 q36e_d 110 /*
	*/ q37_f 111 q38_f 112 q41_f 113 q44_d 114 q45_f 115 q47_f 117 q49_d 119/*
	*/ race 133 hispanic 132/*
	*/ news_iraq 46 news_nba 47 news_baseball 48 news_ukraine 49 /*
	*/ news_scottpeter 50 news_intel 51 news_arafat 52 income 139-140 /*
	*/ using Pew/USPEW2004-TYPO.dat

gen survey="USPEW2004-TYPO"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q32_d q34_d q36a_d q36b_d q36c_d q36d_d q36e_d q37_f q38_f q41_f q44_d q45_f q47_f q49_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q11b_d q11d_d q11g_d q11i_f q20q_d q20r_d q20u_d q20v_d q20bb_f q20cc_f q20dd_d q20ee_d q20ff_d
foreach var of varlist `vars_2' {
recode `var' (1/4=1) (5/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1/4=1) (5=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2005-01NII
{
clear 
infix 1 lines 1: weight 599-602 rid 1-8 sex 18 age 142-143/*
	*/ education 144 party 163-170 partyln 171-178 ideology 179-186 /*
	*/ regist 154 vote2004 187-194 q34_d 113/*
	*/ q40_f 132 q42_f 134 q53_f 140 q54_f 141 /* 
	*/ race 146 hispanic 145 news_iraq 50 news_econ 51 news_gov 52 /*
	*/ news_tsunami 53 news_medication 54 income 152-153 /*
	*/ using Pew/USPEW2005-01NII.dat

gen survey="USPEW2005-01NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
recode q54_f (1/4 6=1) (5 9=0)
local vars_1 q40_f q42_f 
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q34_d q53_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2005-02NII
{
clear 
infix 1 lines 1: weight 1316-1319 rid 1-4 sex 20 age 172-173/*
	*/ education 174 party 185 partyln 186 ideology 187 /*
	*/ regist 183 vote2004 188/*
	*/ q12_d 58 q19a_d 101 q19b_d 102 q19c_d 103 q19d_d 104 q19e_d 105/*
	*/ q20_d 106 q26_d 126 q36_f 143 q38_f 145 q40_f 147 q48_d 155/*
	*/ q1_f 156 q2_f 157 q3_f 158/*
	*/ race 176 hispanic 175/*
	*/ news_iraq 48 news_bushsocsec 49 news_mjackson 50 news_iraqgov 51 /*
	*/ news_socsec 52 news_nkorea 53 income 181-182 /* 
	*/ using Pew/USPEW2005-02NII.dat

* q1_f q2_f q3_f = g1 g2 g3	
	
gen survey="USPEW2005-02NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q12_d q19a_d q19b_d q19c_d q19d_d q19e_d q20_d q36_f q38_f q36_f q40_f q48_d q1_f q2_f q3_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q26_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2005-05NII
{
clear 
infix 1 lines 1: weight 194-197 rid 1-4 sex 25 age 117-118/*
	*/ education 119-120 party 133 partyln 134 ideology 135 /*
	*/ regist 131 vote2004 136 q22_d 77 q24_d 79/*
	*/ q29a_d 85 q29b_d 86 q29c_d 87 q29d_d 88 q29e_d 89 q29f_d 90/*
	*/ race 122 hispanic 121/*
	*/ news_bushsocsec 49 news_gas 50 news_econ 51 news_iraq 52 news_pope 53 /*
	*/ income 1129-1130 /*
	*/ using Pew/USPEW2005-05NII.dat
	
gen survey="USPEW2005-05NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q22_d q24_d q29a_d q29b_d q29c_d q29d_d q29e_d q29f_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2005-06NII
{
clear 
infix 1 lines 1: weight 252-255 rid 1-4 sex 112 age 113-114/*
	*/ education 115 party 127 partyln 128 ideology 129 /*
	*/ regist 125 vote2004 130 q20_f 91 q22_f 93 q37_d 111/*
	*/ race 117 hispanic 116/*
	*/ news_iraq 24 news_deepthroat 25 news_newsweek 26 news_eu 27 /*
	*/ news_bushsocsec 28 news_mjackson 29 news_stemcells 30 news_marijuana 31 /*
	*/ income 123-124 /*
	*/ using Pew/USPEW2005-06NII.dat

gen survey="USPEW2005-06NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q20_f q22_f q37_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2005-apw
{
clear 
infix 1 lines 1: weight 609-612 rid 1-4 sex 22 age 240-241/*
	*/ education 242 party 254 partyln 255 ideology 256 /*
	*/ regist 252 vote2004 257 q9_f 164 q11_f 166 q13_f 168/*
	*/ q14a_f 169 q14b_f 170 q14c_f 171 q14d_f 172 q14e_f 173 q14f_f 174 q14g_f 175/*
	*/ q19_f 192 q21_f 194 q24_f 197 q25_f 198 q26_f 199 q27_f 200/*
	*/ q34_f 207 q35_f 208 q36_f 209 q41_f 221 q43_f 236 q45_f 238/*
	*/ race 244 hispanic 243/*
	*/ news_iraqgov 129 news_pakistan 130 news_birdflu 131 news_germany 132 /*
	*/ news_bali 133 news_gas 134 news_hurricane 135 /*
	*/ income 250-251 /*
	*/ using Pew/uspew2005-apw.dat

gen survey="uspew2005-apw"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q9_f q11_f q13_f q14a_f q14b_f q14c_f q14d_f q14e_f q14f_f q14g_f q19_f q21_f q25_f q26_f q27_f q34_f q35_f q36_f q41_f q43_f q45_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q24_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2005-die
{
clear 
infix 1 lines 1: weight 404-407 rid 1-4 sex 21 age 81-82/*
	*/ education 83 party 98 partyln 99 ideology 100 /*
	*/ regist 96 vote2004 101 q40_d 75 q42_d 77 q43_d 78/*
	*/ race 85 hispanic 84 income 94-95 /*
	*/ using Pew/uspew2005-die.dat

gen survey="uspew2005-die"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q40_d q42_d q43_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** USPEW2005-RELIG
{
clear 
infix 1 lines 1: weight 399-402 rid 1-4 sex 40 age 146-147/*
	*/ education 148 party 156 partyln 157 ideology 158 /*
	*/ regist 154 vote2004 159 /*
	*/ q3a_d 44 q3b_d 45 q3c_d 46 q3d_d 47 q3e_d 48 /*
	*/ q3f_d 49 q3g_d 50 q3h_d 51 q3i_d 52 q3j_d 53 /*
	*/ q6_f 54 q8_f 56 q21_d 87 q22_f 88 q23_f 89/*
	*/ race 150 hispanic 149 income 152-153 /*
	*/ using Pew/USPEW2005-RELIG.dat

gen survey="USPEW2005-RELIG"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q3a_d q3b_d q3c_d q3d_d q3e_d q3f_d q3g_d q3h_d q3i_d q3j_d q8_f q22_f q23_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q6_f q21_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-01nii
{
clear 
infix 1 lines 1: weight 677-680 rid 1-4 sex 23 age 131-132/*
	*/ education 133 party 145 partyln 146 ideology 147 /*
	*/ regist 143 vote2004 148 /*
	*/ q45_d 99 q46_d 100 q48_d 102 q53_f 103 q55_f 105 q57_f 107/*
	*/ q58_f 108 q70a_d 122 q70b_d 123 q70c_d 124 q70d_d 125/*
	*/ q71_d 126 q73_f 128/*
	*/ race 135 hispanic 134/*
	*/ news_iraq 36 news_scourt 37 news_wiretaps 38 news_flood 39 /*
	*/ news_congressbribe 40 news_miners 41 /*
	*/ income 141-142 /*
	*/ using Pew/uspew2006-01nii.dat

gen survey="uspew2006-01nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q45_d q46_d q48_d q53_f q55_f q57_f q58_f q70a_d q70b_d q70c_d q70d_d q71_d q73_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-03nii
{
clear 
infix 1 lines 1: weight 1854-1857 rid 1-4 sex 20 age 153-154/*
	*/ education 155 party 167 partyln 168 ideology 169 /*
	*/ regist 165 vote2004 170 /*
	*/ q11_d 48 q14_d 51 q28_f 75 q29_d 76 q33_d 90 q34_d 92/*
	*/ q60_f 133 q63_f 136 q65_f 138 q69_f 140/*
	*/ race 157 hispanic 156/*
	*/ news_iraq 40 news_usports 41 news_hurricane 42 news_cheney 43 /*
	*/ news_lobbyists 44 news_birdflu 45 news_iran 46 news_abortion 47 /*
	*/ income 163-164 /*
	*/ using Pew/uspew2006-03nii.dat

gen survey="uspew2006-03nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q11_d q14_d q28_f q33_d q34_d q60_f q63_f q65_f q69_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q29_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-04nii
{
clear 
infix 1 lines 1: weight 868-871 rid 1-4 sex 20 age 115-116/*
	*/ education 117 party 129 partyln 130 ideology 133 /*
	*/ regist 127 vote2004 134 /*
	*/ q1_d 55 q2_d 56 q45_f 97 q47_f 99 q53_f 105/*
	*/ race 119 hispanic 118/*
	*/ news_iraq 32 news_immigration 33 news_france 34 news_tomdelay 35 /*
	*/ news_couric 36 news_moussaoui 37 /*
	*/ income 125-126 /*
	*/ using Pew/uspew2006-04nii.dat

* q1 q2 = c1 c2	
	
gen survey="uspew2006-04nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q1_d q2_d q45_f q47_f q53_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-06nii
{
clear 
infix 1 lines 1: weight 281-284 rid 1-4 sex 28 age 148-149/*
	*/ education 150 party 262 partyln 263 ideology 268 /*
	*/ regist 260 vote2004 269 /*
	*/ q37_d 80 q39_d 82 q50_f 88 q52_f 90 q53_f 91 q54_f 92/*
	*/ race 152 hispanic 151/*
	*/ news_iraq 40 news_gas 41 news_elections 42 news_immigration 43 /*
	*/ news_iran 44 news_lobbyists 45 news_soccer 46 news_zarqawi 47 news_marines 48/*
	*/ income 258-259 /*
	*/ using Pew/uspew2006-06nii.dat

gen survey="uspew2006-06nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q37_d q39_d q50_f q52_f q53_f q54_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-08NII
{
clear 
infix 1 lines 1: weight 196-199 rid 1-5 sex 22 age 160-161/*
	*/ education 162 party 174 partyln 175 ideology 176 /*
	*/ regist 172 vote2004 177 /*
	*/ q19_f 97 q21_f 99 q27_f 111 q28_f 112 q64_f 150/*
	*/ q65_f 151 q66_f 152 q68_f 154/*
	*/ race 164 hispanic 163/*
	*/ news_iraq 38 news_weather 39 news_israel 40 news_gas 41 news_immigration 42 /*
	*/ news_iran 43 news_elections 44 news_castro 45 news_melgibson 46 news_senlieberman 47 /*
	*/ news_britterror 48 income 170-171 /*
	*/ using Pew/uspew2006-08NII.dat

gen survey="uspew2006-08NII"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q19_f q21_f q27_f q64_f q65_f q66_f q68_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q28_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-09nii
{
clear 
infix 1 lines 1: weight 166-169 rid 1-8 sex 25 age 129-130/*
	*/ education 131 party 144 partyln 146 ideology 149 /*
	*/ regist 142 vote2004 150 /*
	*/ q31_d 104 q41_d 106 q42_d 107 q44_f 110 q45_f 111/*
	*/ q46_f 112 q55_f 117 q58_f 119 q59_f 120 q61_f 121/*
	*/ race 133 hispanic 132/*
	*/ news_iraq 43 news_elections 44 news_iran 45 news_jonbenet 46 /*
	*/ news_911 47 news_steveirwin 48 news_terror 49 income 140-141 /*
	*/ using Pew/uspew2006-09nii.dat

gen survey="uspew2006-09nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q31_d q41_d q42_d q44_f q45_f q46_f q55_f q58_f q59_f q61_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-12nii
{
clear 
infix 1 lines 1: weight 546-549 rid 1-4 sex 21 age 413-414/*
	*/ education 415 party 528 partyln 529 ideology 530 /*
	*/ regist 526 vote2004 531 /*
	*/ q12_f 367 q13_f 368 q19c_d 376 q20_f 377 q22_f 379 q26_f 383/*
	*/ q31a_f 388 q31b_f 389 q31c_f 390 q31d_f 390/*
	*/ q37_f 395 q42a_d 404 q42b_d 405 q42bb_d 406 q42c_d 407/*
	*/ q42cc_d 408 q42d_f 409 q44_f 411/*
	*/ race 417 hispanic 416/*
	*/ news_iraq 261 news_democrats 262 news_sudan 263 news_russianspy 264 /*
	*/ news_hurricane 265 income 524-525 /*
	*/ using Pew/uspew2006-12nii.dat

gen survey="uspew2006-12nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)

local vars_1 q12_f q13_f q19c_d q20_f q22_f q26_f q31a_f q31b_f q31c_f q31d_f q37_f q42a_d q42b_d q42bb_d q42c_d q42cc_d q42d_f q44_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-elec
{
clear 
infix 1 lines 1: weight 116-119 rid 1-6 sex 81 age 83-84/*
	*/ education 85 party 96 partyln 98 ideology 101 /*
	*/ regist 29 vote2004 102  /*
	*/ q23_d 63 q24_d 64 q25_d 65 q28_f 72 q30_f 74/*
	*/ race 87 hispanic 86 news_elections 32 income 94-95 /*
	*/ using Pew/uspew2006-elec.dat

gen survey="uspew2006-elec"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q23_d q24_d q25_d q28_f q30_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-postelec
{
clear 
infix 1 lines 1: weight 907-910 rid 1-4 sex 22 age 821-822/*
	*/ education 823 party 887 partyln 889 ideology 892 /*
	*/ regist 30 vote2004 893  /*
	*/ q42_f 802 q44_f 804 q49_f 809 q50_f 810 q51_f 811/*
	*/ race 825 hispanic 824/*
	*/ news_iraq 25 news_elections 26 news_econ 27 news_secdef 28 news_minister 29 /*
	*/ income 885-886 /*
	*/ using Pew/uspew2006-postelec.dat

gen survey="uspew2006-postelec"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q42_f q44_f q49_f q50_f q51_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2006-turnout
{
clear 
infix 1 lines 1: weight 843-846 rid 1-4 sex 396 age 397-398/*
	*/ education 399 party 460 partyln 462 ideology 465 /*
	*/ regist 31 vote2004 466  /*
	*/ q54_f 386 q56_f 388 q57_f 389 q58_f 390/*
	*/ race 401 hispanic 400 news_elections 35 income 458-459 /*
	*/ using Pew/uspew2006-turnout.dat

gen survey="uspew2006-turnout"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q54_f q56_f q57_f q58_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-01nii
{
clear 
infix 1 lines 1: weight 789-793 rid 1-4 sex 22 age 640-641/*
	*/ education 642 party 754 partyln 755 ideology 756 /*
	*/ regist 752 /*
	*/ q30_d 610 q37_f 626 q39_f 628 q44_f 633/*
	*/ race 644 hispanic 643 news_iraq 298 news_saddam 299 news_ford 300 /*
	*/ news_somalia 301 news_democrats 302 news_weather 303 income 750-751 /*
	*/ using Pew/uspew2007-01nii.dat

* vote	
	
gen survey="uspew2007-01nii"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q30_d q37_f q39_f q44_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-02pol
{
clear 
infix 1 lines 1: weight 1028-1031 rid 1-4 sex 955 age 956-957/*
	*/ education 958 party 1020 partyln 1021 ideology 1022 /*
	*/ regist 1018 /*
	*/ q33_d 835 q37_f 929 q39_f 931 q44_f 936 q45_f 937 q57_f 954/*
	*/ race 960 hispanic 959 income 1016-1017 /*
	*/ using Pew/uspew2007-02pol.dat

* vote	
	
gen survey="uspew2007-02pol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q33_d q37_f q39_f q44_f q45_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q57_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-03pol
{
clear 
infix 1 lines 1: weight 1190-1193 rid 1-8 sex 98 age 99-100/*
	*/ education 101 party 216 partyln 218 ideology 219 /*
	*/ regist 214 /*
	*/ q45_f 82 q47_f 84 q51_f 88 q56_d 93/*
	*/ race 103 hispanic 102 income 212-213 /*
	*/ using Pew/uspew2007-03pol.dat

* vote	
	
gen survey="uspew2007-03pol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q45_f q47_f q51_f q56_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-04pol
{
clear 
infix 1 lines 1: weight 179-182 rid 1-8 sex 24 age 155-156/*
	*/ education 157 party 36 partyln 38 ideology 171 /*
	*/ regist 169 /*
	*/ q20_d 77 q21_d 78 q36_d 123 q45_f 126 q47_f 128 q50_f 131 q51_f 132/*
	*/ q57a_f 138 q57b_f 139 q57c_f 140 q57d_f 141/*
	*/ race 159 hispanic 158/*
	*/ income 167-168 /*
	*/ using Pew/uspew2007-04pol.dat

* vote	
	
gen survey="uspew2007-04pol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q20_d q21_d q36_d q45_f q47_f q50_f q51_f q57a_f q57b_f q57c_f q57d_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

duplicates drop rid, force // a few duplicated responses for some reason
reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-06pol
{
clear 
infix 1 lines 1: weight 321-324 rid 1-8 sex 25 age 92-93/*
	*/ education 94 party 307 partyln 309 ideology 310 /*
	*/ regist 305 /*
	*/ q40_d 68 q41_d 69 q42_d 70 q55_f 74/*
	*/ q56_f 75 q57_f 76 q59_f 78 q65_f 90/*
	*/ race 96 hispanic 95/*
	*/ income 303-304 /*
	*/ using Pew/uspew2007-06pol.dat

* vote	
	
gen survey="uspew2007-06pol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q40_d q41_d q42_d q55_f q56_f q57_f q59_f q65_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-09pol
{
clear 
infix 1 lines 1: weight 494-497 rid 1-8 sex 237 age 238-239/*
	*/ education 240 party 148 partyln 149 ideology 254 /*
	*/ regist 252 /*
	*/ q47_f 210 q49_f 212 /*
	*/ race 242 hispanic 241 income 250-251 /*
	*/ using Pew/uspew2007-09pol.dat

* vote	
	
gen survey="uspew2007-09pol"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q47_f q49_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-10pol
{
clear 
infix 1 lines 1: pollmethod 12 weight 1195-1198 rid 1-5 sex 638 age 639-640/*
	*/ education 641 party 655 partyln 656 ideology 659 /*
	*/ regist 653 llweight 1187-1190 coweight 1191-1194/*
	*/ q56_d 630 q57_f 631 q59_f 633 q63_f 637/*
	*/ race 643 hispanic 642 income 651-652 /*
	*/ using Pew/uspew2007-10pol.dat

* vote	
	
gen survey="uspew2007-10pol"	
* gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q56_d q57_f q59_f q63_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-11prim
{
clear
infix 1 lines 1: weight 927-931 rid 1-4 sex 25 age 850-851/*
	*/ education 852 party 190 partyln 191 ideology 914 /*
	*/ regist 188 /*
	*/ q32_f 793 q35_d 813 q36_d 814 q37_d 816 q38_d 817 q39_d 818/*
	*/ q40_d 819 q41_d 820 q42_f 821 q44_f 823 q45_d 824 /*
	*/ race 854 hispanic 853 news_elections 187 income 912-913 /*
	*/ using Pew/uspew2007-11prim.dat

* vote	
	
gen survey="uspew2007-11prim"	
gen pollmethod=1
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q32_f q35_d q36_d q37_d q38_d q39_d q40_d q41_d q42_f q44_f q45_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}	
*** uspew2007-12pol	
{	
clear
infix 1 lines 1: pollmethod 30 weight 675-679 rid 1-7 sex 538 age 539-540/*
	*/ education 541 party 223 partyln 224 ideology 633 /*
	*/ regist 221 llweight 665-669 coweight 670-674/*
	*/ q48_d 529 q49_d 530 q51_f 531 q53_f 533/*
	*/ race 543 hispanic 542 income 631-632 /*
	*/ using Pew/uspew2007-12pol.dat

* vote	
	
gen survey="uspew2007-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q48_d q49_d q51_f q53_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2007-sdt07
{
clear
infix 1 lines 1: weight 146-150 rid 1-4 sex 21 age 119-120/*
	*/ education 121 party 131 partyln 133 ideology 134 /*
	*/ regist 129 sample 18/*
	*/ q9a_d 39 q9b_d 40 q9c_d 41 q22_d 54 q29_d 62 q31_d 64 /*
	*/ q34_d 65 q36_d 66 q59_d 103 q60_d 104/*
	*/ race 47 hispanic 46 income 127-128 /*
	*/ using Pew/uspew2007-sdt07.dat

drop if sample !=1	
* vote	
gen pollmethod=1	
gen survey="uspew2007-sdt07"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q9a_d q9b_d q9c_d q29_d q34_d q59_d q60_d	 
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q22_d q31_d q36_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}	
*** uspew2008-01pol	
{	
clear
infix 1 lines 1: weight 375-378 rid 1-5 sex 19 age 270-271/*
	*/ education 272 party 195 partyln 196 ideology 285 /*
	*/ regist 193 /*
	*/ q35a_d 266 q35b_d 267 q35c_d 268 q35d_d 269/*
	*/ race 274 hispanic 273 income 282-283 /*
	*/ using Pew/uspew2008-01pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q35a_d q35b_d q35c_d q35d_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace	
}
*** uspew2008-02pol
{
clear
infix 1 lines 1: weight 143-145 rid 1-4 sex 121 age 122-123/*
	*/ education 124 party 27 partyln 28 ideology 134 /*
	*/ regist 25 /*
	*/ q55_f 76 q57_f 78 q63_d 91 q65_d 93/*
	*/ q66a_d 94 q66b_d 95 q66c_d 96 q66d_d 97 q66e_d 98 q66f_d 99 q66g_d 100 /*
	*/ q72_d 105 q73_f 106 q74_f 107 q79_f 108 q81_f 110 q86_d 112/*
	*/ race 126 hispanic 125 income 132-133 /*
	*/ using Pew/uspew2008-02pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-02pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q55_f q57_f q63_d q65_d q66a_d q66b_d q66c_d q66d_d q66e_d q66f_d q66g_d q72_d q73_f q74_f q79_f q81_f q86_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace	
}	
*** uspew2008-03pol	
{	
clear
infix 1 lines 1: weight 151-154 rid 1-4 sex 118 age 119-120/*
	*/ education 121 party 23 partyln 24 ideology 133 /*
	*/ regist 21 /*
	*/ q82a_d 107 q82b_d 108 q82c_d 109 q82f_d 112 /*
	*/ race 123 hispanic 122 income 131-132 /*
	*/ using Pew/uspew2008-03pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-03pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q82a_d q82b_d q82c_d q82f_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace
}	
*** uspew2008-05pol	
{	
clear
infix 1 lines 1: weight 215-219 rid 1-4 sex 16 age 140-141/*
	*/ education 142 party 55 partyln 56 ideology 153 /*
	*/ regist 22 q30a_f 100 q30b_f 101 q30c_f 102 q30d_f 103 q30e_f 104 q30f_f 105/*
	*/ q34_d 108 q35_d 109/*
	*/ race 144 hispanic 143 income 151-152 /*
	*/ using Pew/uspew2008-05pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-05pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q30a_f q30b_f q30c_f q30d_f q30e_ q30f_f q34_d q35_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR.dta
saveold SNR.dta, replace	
}	
*** uspew2008-09late
{
clear
infix 1 lines 1: pollmethod 26 weight 129-133 rid 1-5 sex 27 age 86-87/*
	*/ education 88 party 103 partyln 104 ideology 105 /*
	*/ regist 30 vote2004 106 llweight 134-139 coweight 140-145/*
	*/ q44_d 79 q45_d 80 q47a_d 82 q47d_d 85/*
	*/ race 123 hispanic 89 income 101-102 /*
	*/ using Pew/uspew2008-09late.dat

gen survey="uspew2008-09late"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q44_d q45_d q47a_d q47d_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2008-09mid	
{	
clear
infix 1 lines 1: pollmethod 21-22 weight 239-243 rid 1-5 sex 34 age 188-189/*
	*/ education 190 party 204 partyln 205 ideology 208 /*
	*/ regist 40 vote2004 209 llweight 244-248 coweight 249-253/*
	*/ q47_f 166 q49_f 168 q51_f 170 q53_f 171 q55_d 172 q56_d 173/*
	*/ q57a_d 174 q57b_d 175 q57c_d 176 q57d_d 177 q57e_d 178 q57f_d 179/*
	*/ q64_f 186 q65_f 187/*
	*/ race 232 hispanic 191 news_elections 38 income 202-203 /*
	*/ using Pew/uspew2008-09mid.dat

tab pollmethod	
gen survey="uspew2008-09mid"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q47_f q49_f q51_f q53_f q55_d q56_d q57a_d q57b_d q57c_d q57d_d q57e_d q57f_d q64_f q65_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}	
*** uspew2008-10late
{	
clear
infix 1 lines 1: pollmethod 39 weight 199-203 rid 1-5 sex 42 age 96-97/*
	*/ education 98 party 170 partyln 171 ideology 172 /*
	*/ regist 47 vote2004 173 llweight 204-208 coweight 209-213/*
	*/ q14_d 80 q16a_d 83 q16b_d 84 q16c_d 85 q16d_d 86 q17_d 87/*
	*/ q19_f 89 q22a_d 90 q22b_d 91 q22d_d 93/*
	*/ race 105 hispanic 99 news_elections 45 income 168-169 /*
	*/ using Pew/uspew2008-10late.dat

tab pollmethod	
gen survey="uspew2008-10late"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q16a_d q16b_d q16c_d q16d_d q17_d q19_f q22a_d q22b_d q22d_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q14_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2008-10mid	
{	
clear
infix 1 lines 1: pollmethod 14 weight 322-326 rid 1-5 sex 39 age 214-215/*
	*/ education 216 party 293 partyln 294 ideology 295 /*
	*/ regist 43 vote2004 296 llweight 327-331 coweight 332-336/*
	*/ q34_d 195 q36_f 197 q38_f 199/*
	*/ race 223 hispanic 217 news_elections 42 /*
	*/ income 291-292 /*
	*/ using Pew/uspew2008-10mid.dat

tab pollmethod	
gen survey="uspew2008-10mid"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q34_d q36_f q38_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2008-11elec	
{
clear
infix 1 lines 1: pollmethod 33 weight 181-185 rid 1-5 sex 34 age 91-92/*
	*/ education 94 party 112 partyln 113 ideology 114 /*
	*/ regist 39 vote2004 117 llweight 156-159 coweight 160-163/*
	*/ q17_f 90/*
	*/ race 102 hispanic 96 news_elections 37 income 110-111 /*
	*/ using Pew/uspew2008-11elec.dat

tab pollmethod	
gen survey="uspew2008-11elec"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q17_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2008-12pol
{
clear
infix 1 lines 1: pollmethod 37 weight 200-206 rid 1-6 sex 45 age 153-154/*
	*/ education 156 party 178 partyln 179 ideology 180 /*
	*/ regist 176 vote2004 182 llweight 207-213 coweight 214-220/*
	*/ q15b_d 74 q15c_d 75 q15e_d 76 q50_d 124/*
	*/ q53a_d 126 q53b_d 127 q53c_d 128/*
	*/ race 164 hispanic 158 income 174-175 /*
	*/ using Pew/uspew2008-12pol.dat

tab pollmethod	
gen survey="uspew2008-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q50_d q53a_d q53b_d q53c_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q15b_d q15c_d q15e_d 
foreach var of varlist `vars_2' {
recode `var' (1/4=1) (5/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2008-sdt08
{
clear
infix 1 lines 1: pollmethod 15 weight 205-209 rid 1-8 sex 27 age 147-148/*
	*/ education 149 party 167 partyln 168 ideology 169 /*
	*/ regist 165 /*
	*/ q10_d 47/*
	*/ race 151 hispanic 150 income 157-158 /*
	*/ using Pew/uspew2008-sdt08.dat

* vote2004	
tab pollmethod	
gen survey="uspew2008-sdt08"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q10_d 
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2009-01pol
{
clear
infix 1 lines 1: pollmethod 27 weight 184-188 rid 1-6 sex 144 age 145-146/*
	*/ education 147 party 165 partyln 166 ideology 167 /*
	*/ regist 163 vote2008 168 llweight 189-193 coweight 194-198 /*
	*/ q3_f 111 q33a_f 104 q33b_f 105 q33c_f 106 q33d_f 107/*
	*/ q33e_f 108 q33f_f 109 q33g_f 110/*
	*/ q34_f 112 q36_f 114 q49_f 133/*
	*/ q51_f 135 q58_f 140 q59_f 141 q60_f 142 q62_f 143/*
	*/ race 154 hispanic 148 income 161-162 /*
	*/ using Pew/uspew2009-01pol.dat

* q3_f = qa3	
tab pollmethod	
gen survey="uspew2009-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q33a_f q33b_f q33c_f q33d_f q33e_f q33f_f q33g_f q34_f q36_f q49_f q51_f q58_f q59_f q60_f q62_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q3_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2009-02pol
{
clear
infix 1 lines 1: pollmethod 27 weight 191-195 rid 1-6 sex 141 age 142-143/*
	*/ education 145 party 170 partyln 171 ideology 172 /*
	*/ regist 168 vote2008 174 llweight 196-200 coweight 201-205 /*
	*/ q1_d 101 q46_d 138 q47_d 139 q48_f 140/*
	*/ race 155 hispanic 149 income 166-167 /*
	*/ using Pew/uspew2009-02pol.dat

* q1_d = qa
tab pollmethod	
gen survey="uspew2009-02pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q1_d q47_d q48_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q1_d q46_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2009-03pol
{
clear
infix 1 lines 1: pollmethod 27 weight 133-137 rid 1-6 sex 94 age 95-96/*
	*/ education 98 party 119 partyln 120 ideology 121 /*
	*/ regist 117 llweight 138-142 coweight 143-147 /*
	*/ q13_d 54 q14_d 55 q15_d 56 q36_d 71/*
	*/ hispanic 102 race 108 income 115-116 /*
	*/ using Pew/uspew2009-03pol.dat

* vote2008	
tab pollmethod	
gen survey="uspew2009-03pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q14_d q15_d q36_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q13_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2009-05sci
{
clear
infix 1 lines 1: pollmethod 13 weight 172-176 rid 1-6 sex 112 age 113-114/*
	*/ education 115 party 145 partyln 146 ideology 147 /*
	*/ regist 143 llweight 177-181 coweight 182-186 /*
	*/ q50a_d 98 q50b_d 99 q51_d 101/*
	*/ hispanic 120 race 126 income 141-142 /*
	*/ using Pew/uspew2009-05sci.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-05sci"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q50a_d q50b_d q51_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-06
{
clear
infix 1 lines 1: pollmethod 13 weight 74-78 rid 1-6 sex 56 age 57-58/*
	*/ education 64 party 59 /*
	*/ q1a_d 27 q1b_d 28 q1c_d 29 q1d_f 30 q1e_d 31/*
	*/ q1f_d 32 q1g_f 33 q1h_f 34 q1i_f 35 q1j_d 36/*
	*/ q1k_d 37 q1l_d 38 q1m_d 39 q1n_d 40 q12_d 55/*
	*/ hispanic 65 race 66 income 68-69 /*
	*/ using Pew/uspew2009-06.dat

recode hispanic (1=1) (2=2) (8/9=9)	
recode race (1=1) (2=2) (3=3) (4/6=4) (8/9=9)
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* partyln
* ideology	
* regist
* vote2008	
tab pollmethod 
gen survey="uspew2009-06"

local vars_1 q1a_d q1b_d q1c_d q1d_f q1e_d q1f_d q1g_f q1h_f q1i_f q1j_d q1k_d q1l_d q1m_d q1n_d q12_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-06pol
{
clear
infix 1 lines 1: pollmethod 28 weight 224-228 rid 1-6 sex 174 age 175-176/*
	*/ education 177 party 202 partyln 203 ideology 204 /*
	*/ regist 200 llweight 229-233 coweight 234-238/*
	*/ q32a_d 128 q32b_d 129 q32c_d 130/*
	*/ q47a_f 151 q47b_f 152 q47c_f 153 q47d_f 154 q47e_f 155 q47f_f 156 q47g_f 157/*
	*/ q56_d 170/*
	*/ hispanic 181 race 187 income 198-199 /*
	*/ using Pew/uspew2009-06pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-06pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q32a_d q32b_d q32c_d q47a_f q47b_f q47c_f q47d_f q47e_f q47f_f q47g_f q56_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-09
{
clear
infix 1 lines 1: pollmethod 7 weight 134-138 rid 1-6 sex 79 age 80-81/*
	*/ education 86 party 107 partyln 108 ideology 109 /*
	*/ regist 105 llweight 124-128 coweight 129-133/*
	*/ q2_d 66 q49_f 68/*
	*/ hispanic 91 race 92 income 89-90 /*
	*/ using Pew/uspew2009-09.dat

recode hispanic (1=1) (2=2) (8/9=9)
recode race (1=1) (2=2) (3=3) (4=4) (8/9=9)	
* q2_d = qh2	
replace age=99 if age==98	
replace regist=9 if regist==8
replace party=9 if party==8
replace partyln=9 if party==7 | party==8
replace ideology=9 if ideology==8
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* vote2008	
tab pollmethod 
gen survey="uspew2009-09"

local vars_1 q2_d q49_f
foreach var of varlist `vars_1' {
recode `var' (1/7=1) (8/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 150-154 rid 1-6 sex 41 age 105-106/*
	*/ education 107 party 131 partyln 132 ideology 133 /*
	*/ regist 129/*
	*/ q17_d 59 q19_d 61 q32a_d 69 q32b_d 70 q32c_d 71 /* // q32 examples for valid volunteered response
	*/ q46_d 85 q49a_d 89 q49b_d 90 q49c_d 91 q49d_d 92/*
	*/ q49e_d 93 q49f_d 94 q56_d 98 q60_f 100 q62_f 102 q64_f 104/*
	*/ hispanic 108 race 116 income 127-128 /*
	*/ using Pew/uspew2009-10pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-10pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q17_d q32a_d q32b_d q32c_d q46_d q49a_d q49b_d q49c_d q49d_d q49e_d q49f_d q56_d q60_f q62_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q19_d q64_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-10sdt
{
clear
infix 1 lines 1: pollmethod 7 weight 221-225 rid 1-6 sex 46 age 163-164/*
	*/ education 165 party 175 partyln 176 ideology 178 /*
	*/ regist 173/*
	*/ q8_d 69 q10_d 71 q38_d 95/*
	*/ hispanic 75 race 80 income 171-172 /*
	*/ using Pew/uspew2009-10sdt.dat

recode race (1=1) (2=2) (3=3) (5=4) (9=9)	
drop if pollmethod==2 | pollmethod==4
replace pollmethod=2 if pollmethod==3	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* vote2008	
tab pollmethod 
gen survey="uspew2009-10sdt"

local vars_2 q8_d q10_d q38_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-11
{
clear
infix 1 lines 1: pollmethod 11 weight 79-83 rid 1-6 sex 50 age 51-52/*
	*/ education 63 party 55 partyln 56 /*
	*/ q2_d 22 q6_d 37/*
	*/ q7a_f 38 q7b_f 39 q7c_f 40 q7d_f 41 q7e_f 42 q12_d 47/*
	*/ hispanic 65 race 66 income 69-70 /*
	*/ using Pew/uspew2009-11.dat

recode race (1=1) (2=2) (3=3) (4/6=4) (8/9=9)
recode hispanic (1=1) (2=2) (8/9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* vote2008
* ideology	
* regist
tab pollmethod 
gen survey="uspew2009-11"

local vars_1 q2_d q7a_f q7b_f q7c_f q7d_f q7e_f q12_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q6_d 
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 223-227 rid 1-6 sex 160 age 161-162/*
	*/ education 165 party 194 partyln 195 ideology 197/*
	*/ regist 192 llweight 213-217 coweight 218-222/*
	*/ q25_d 92/*
	*/ hispanic 170 race 176 income 190-191 /*
	*/ using Pew/uspew2009-12pol.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q25_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-apw
{
clear
infix 1 lines 1: pollmethod 45 weight 386-390 rid 1-6 sex 48 age 261-262/*
	*/ education 263-264 party 305-306 partyln 307-308 ideology 309-310/*
	*/ regist 301-302 llweight 376-380 coweight 381-385/*
	*/ q21_f 141-142 q23_f 145-146 q26a_f 149-150 q26b_f 151-152 q26c_f 153-154/*
	*/ q26d_f 155-156 q26e_f 157-158 q26f_f 159-160 q26g_d 161-162 q26h_f 163-164 q26i_f 165-166/*
	*/ q31_d 191-192 q40_f 197-198 q44_f 211-212/*
	*/ q48a_f 217-218 q48b_f 219-220 q48c_f 221-222 q53_f 223-224 q55_f 227-228/*
	*/ q59_f 237-238 q60_f 239-240 q62_f 243-244 q63_f 245-246 /*
	*/ q67_d 253-254 q68_d 255-256 q69_f 257-258 q70_f 259-260/*
	*/ hispanic 265-266 race 281-282 income 299-300 /*
	*/ using Pew/uspew2009-apw.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-apw"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q21_f q23_f q26a_f q26b_f q26c_f q26d_f q26e_f q26f_f q26g_d q26h_f q26i_f q31_d q40_f q44_f q48a_f q48b_f q48c_f q53_f q55_f q60_f q62_f q63_f q68_d q69_f q70_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q59_f q67_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-relig
{
clear
infix 1 lines 1: pollmethod 29 weight 340-344 rid 1-7 sex 273 age 274-275/*
	*/ education 277 party 304 partyln 305 ideology 306/*
	*/ regist 302 llweight 330-334 coweight 335-339/*
	*/ q125_d 65 q146a_d 86 q146b_d 87/*
	*/ hispanic 282 race 288 income 300-301 /*
	*/ using Pew/uspew2009-relig.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-relig"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q125_d q146a_d q146b_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2009-values
{
clear
infix 1 lines 1: pollmethod 28 weight 275-279 rid 1-7 sex 220 age 221-222/*
	*/ education 223 party 131 partyln 133 ideology 248/*
	*/ regist 246 llweight 280-284 coweight 285-289/*
	*/ vote2008 136 q13a_d 59 q12_d 80 q13_d 81 q14_d 82/*
	*/ q16_f 84 q17a_f 85 q18a_d 86 q18b_d 87 q18c_d 88/*
	*/ q19a_d 89 q19b_d 90 q19c_d 91 q19bb_d 98 q20b_d 99/*
	*/ q30a_d 139 q30d_d 142 q30e_d 143 q30f_d 144 q30g_d 145/*
	*/ q30k_d 150 q30n_d 153 q30p_f 155 q30u_f 159 q30x_f 161 q30z_d 163/*
	*/ q30cc_d 166 q31g_d 172 q31h_d 173 q31i_d 174 q31j_d 175/*
	*/ q31o_d 178 q31p_d 179 q31gg_d 191 q31hh_d 192/*
	*/ q25b_f 196 q27a_d 198 q27b_d 199 q27c_d 200 q27d_d 201 q27e_d 202/*
	*/ hispanic 227 race 233 income 244-245 /*
	*/ using Pew/uspew2009-values.dat

* q13a_d =qa13 | q17a_f = qa17
tab pollmethod 
gen survey="uspew2009-values"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q13a_d q12_d q13_d q14_d q16_f q17a_f q18a_d q18b_d q18c_d q19a_d q19b_d q19c_d q19bb_d q20b_d q30a_d q30d_d q30e_d q30f_d q30g_d q30k_d q30n_d q30p_f q30u_f q30x_f q30z_d q30cc_d q31g_d q31h_d q31i_d q31j_d q31o_d q31p_d q31gg_d q31hh_d q25b_f q27a_d q27b_d q27c_d q27d_d q27e_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-01
{
clear
infix 1 lines 1: pollmethod 13 weight 103-107 rid 1-6 sex 75 age 76-77/*
	*/ education 87 party 79 partyln 80 /*
	*/ q2_f 43/*
	*/ hispanic 89 race 92 news_haiti 41 income 93-94 /*
	*/ using Pew/uspew2010-01.dat

* ideology regist vote2008
* q2_f pewa2
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2010-01"

local vars_1 q2_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 195-199 rid 1-6 sex 137 age 138-139/*
	*/ education 142 party 103 partyln 104 ideology 170/*
	*/ regist 168 vote2008 171 llweight 185-189 coweight 190-194/*
	*/ q36_d 108 q41_d 119 q47_d 122 q48_d 123 /*
	*/ hispanic 147 race 153 income 166-167 /*
	*/ using Pew/uspew2010-01pol.dat

tab pollmethod 
gen survey="uspew2010-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q36_d q41_d q48_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q47_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 195-199 rid 1-6 sex 135 age 136-137/*
	*/ education 140 party 167 partyln 168 ideology 171/*
	*/ regist 165 llweight 185-189 coweight 190-194/*
	*/ q35_d 99 q36_d 100 q37_d 101 q38_d 102 q72_d 126/*
	*/ q73a_d 127 q73b_d 128 q73c_d 129 q73d_d 130/*
	*/ q76_d 132 q77_d 133 q78_d 134/*
	*/ hispanic 144 race 150 income 163-164 /*
	*/ using Pew/uspew2010-02pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-02pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q36_d q37_d q38_d q72_d q73a_d q73b_d q73c_d q73d_d q76_d q77_d q78_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q35_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-03pol
{
clear
infix 1 lines 1: pollmethod 7 weight 197-204 rid 1-6 sex 131 age 132-133/*
	*/ education 134 party 158 partyln 159 ideology 160/*
	*/ regist 156 llweight 181-188 coweight 189-196/*
	*/ q16_d 74 q26_d 81 q27_d 82 q44_d 103 q52_d 125 q53_d 126/*
	*/ hispanic 136 race 144/*
	*/ income 154-155 /*
	*/ using Pew/uspew2010-03pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-03pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q16_d q26_d q27_d q44_d q52_d q53_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-04ear
{
clear
infix 1 lines 1: pollmethod 7 weight 76-80 rid 1-6 sex 38 age 40-41/*
	*/ education 52 party 44 partyln 45 ideology 46/*
	*/ q9_d 35 q10_d 36/*
	*/ hispanic 54 race 56 income 57-58 /*
	*/ using Pew/uspew2010-04ear.dat

* vote2008 regist
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2010-04ear"

local vars_2 q9_d q10_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 181-185 rid 1-6 sex 127 age 128-129/*
	*/ education 132 party 158 partyln 159 ideology 160/*
	*/ regist 156/*
	*/ q23_f 63 q30_d 69 q31_d 70/*
	*/ hispanic 137 race 143 income 154-155 /*
	*/ using Pew/uspew2010-04pol.dat

* vote2008

tab pollmethod 
gen survey="uspew2010-04pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q23_f q30_d q31_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 290-297 rid 1-6 sex 185-186 age 187-188/*
	*/ education 189-190 party 227-228 partyln 229-230 ideology 239-240/*
	*/ regist 223-224 llweight 280-284 coweight 285-289/*
	*/ q42a_d 125-126 q43a_d 129-130 q43b_d 131-132/*
	*/ q50a_d 147-148 q50b_d 149-150 q50c_d 151-152 q50d_d 153-154/*
	*/ q50e_d 155-156 q53_d 157-158 q58_d 161-162 q60_d 165-166 q63_f 171-172/*
	*/ hispanic 191-192 race 207-208 news_elections 53-54 income 221-222 /*
	*/ using Pew/uspew2010-06pol.dat

* vote2008

tab pollmethod 
gen survey="uspew2010-06pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q42a_d q50a_d q50b_d q50c_d q50d_d q50e_d q53_d q58_d q60_d q63_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q43a_d q43b_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-09pi
{
clear
infix 1 lines 1: pollmethod 7 weight 190-194 rid 1-6 sex 113 age 114-115/*
	*/ education 118 party 94 partyln 96 ideology 143/*
	*/ regist 45 vote2008 144 llweight 180-184 coweight 185-189/*
	*/ q30e_d 71 q30f_d 72 q30g_d 73 q31_d 75 /*
	*/ q38_d 83 q39_d 84 q40_d 85 q46_f 88 q47_f 89/*
	*/ hispanic 122 race 128 income 141-142 /*
	*/ using Pew/uspew2010-09pi.dat

tab pollmethod 
gen survey="uspew2010-09pi"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q40_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q30e_d q30f_d q30g_d q31_d q39_d q46_f q47_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

local vars_3 q38_d
foreach var of varlist `vars_3' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 200-204 rid 1-6 sex 128 age 129-130/*
	*/ education 133 party 158 partyln 159 ideology 162/*
	*/ regist 40 vote2008 163 llweight 190-194 coweight 195-199/*
	*/ q48a_d 107 q48b_d 108 q48c_d 109  q48d_d 110/*
	*/ q48e_d 111 q48f_d 112 q73_d 125/*
	*/ hispanic 137 race 143 news_elections 42 income 156-157 /*
	*/ using Pew/uspew2010-10pol.dat

tab pollmethod 
gen survey="uspew2010-10pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q48a_d q48b_d q48c_d q48d_d q48e_d q48f_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q73_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-govtrust
{
clear
infix 1 lines 1: pollmethod 7 weight 227-231 rid 1-6 sex 150 age 151-152/*
	*/ education 155 party 181 partyln 182 ideology 183/*
	*/ regist 179 llweight 217-221 coweight 222-226/*
	*/ q45_d 84 q46_d 86 q67a_d 117 q67d_d 120 q67e_d 121/*
	*/ q68a_d 122 q68b_d 123 q74_d 128/*
	*/ hispanic 159 race 165 news_dc 46 income 176-177 /*
	*/ using Pew/uspew2010-govtrust.dat

* vote2008 partyln
tab pollmethod 
gen survey="uspew2010-govtrust"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q45_d q46_d q67a_d q67d_d q67e_d q68a_d q68b_d q74_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-relig
{
clear
infix 1 lines 1: pollmethod 7 weight 200-204 rid 1-6 sex 143 age 144-145/*
	*/ education 148 party 169 partyln 170 ideology 171/*
	*/ regist 167 llweight 190-194 coweight 195-199/*
	*/ q12a_d 69 q12b_d 70 q12c_d 71 q12d_d 72 q12e_d 73/*
	*/ q13_d 74 q15a_d 81 q15b_d 82/*
	*/ hispanic 152 race 157 income 165-166 /*
	*/ using Pew/uspew2010-relig.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-relig"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q12a_d q12b_d q12c_d q12d_d q12e_d q13_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q15a_d q15b_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2010-wk0506
{
clear
infix 1 lines 1: pollmethod 7 weight 77-81 rid 1-6 sex 56 age 57-58/*
	*/ education 64 party 62 partyln 63 /*
	*/ regist 61 /*
	*/ q2a_d 24 q2b_d 25 q2c_d 26 q2d_d 27/*
	*/ q10a_d 44 q10b_d 45 q10c_d 46 q11_d 47/*
	*/ hispanic 67 race 69 news_econ 32 news_oilleak 33 news_flood 34 /*
	*/ news_carbomb 35 news_police 36 news_greece 37 income 70-71 /*
	*/ using Pew/uspew2010-wk0506.dat

* vote2008 ideology
recode regist (1=1) (2=1) (3=2) (9=9)
tab pollmethod 
gen survey="uspew2010-wk0506"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q2a_d q2b_d q2c_d q2d_d q10a_d q10b_d q10c_d q11_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 178-182 rid 1-6 sex 122 age 123-124/*
	*/ education 125 party 142 partyln 143 ideology 144/*
	*/ regist 140 llweight 168-172 coweight 173-177/*
	*/ q21_f 79 q36_f 111 q39a_f 114 q39b_f 115 q39c_f 116 q39d_f 117/*
	*/ hispanic 126 race 132 income 138-139 /*
	*/ using Pew/uspew2011-01pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q36_f q39a_f q39b_f q39c_f q39d_f 
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q21_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 161-165 rid 1-6 sex 108 age 109-110/*
	*/ education 111 party 127 partyln 128 ideology 129/*
	*/ regist 125 llweight 151-155 coweight 156-160/*
	*/ q17a_d 55 q17b_d 56 q17c_f 57 q17d_d 58 q17e_d 59/*
	*/ q17f_d 60 q17g_d 61 q17h_d 62 q17i_d 63 q17j_d 64/*
	*/ q17k_f 65 q17l_d 66 q17m_d 67 q17n_d 68 q17o_d 69/*
	*/ q17p_d 70 q17q_f 71 q17s_d 72 q18_d 73/*
	*/ q40_d 83 q41a_d 84 q41b_d 85 q41c_d 86 q41d_d 87/* //neither as a valid response - q40
	*/ q41e_d 88 q41f_d 89 q41g_d 90 q41h_d 91 q55_d 95/*
	*/ q56_d 96 q67_d 103 q69_d 104 q73_d 106/*
	*/ hispanic 112 race 118 income 123-124 /*
	*/ using Pew/uspew2011-02pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-02pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q17a_d q17b_d q17c_f q17d_d q17e_d q17f_d q17g_d q17h_d q17i_d q17j_d q17k_f q17l_d q17m_d q17n_d q17o_d q17p_d q17q_f q17s_d q18_d q40_d q41a_d q41b_d q41c_d q41d_d q41e_d q41f_d q41g_d q41h_d q69_d q73_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q55_d q56_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

local vars_3 q67_d
foreach var of varlist `vars_3' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 150-154 rid 1-6 sex 103 age 104-105/*
	*/ education 106 party 123 partyln 124 ideology 125/*
	*/ regist 121 llweight 140-144 coweight 145-149/*
	*/ q7_f 54 q9_f 56 q46a_f 75 q46b_f 76 q46c_f 77/*
	*/ q46d_f 78 q46e_f 79 q58_f 95/*
	*/ hispanic 107 race 113 income 119-120 /*
	*/ using Pew/uspew2011-04pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-04pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q7_f q9_f q46a_f q46b_f q46c_f q46d_f q46e_f q58_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-05pol
{
clear
infix 1 lines 1: pollmethod 7 weight 179-183 rid 1-6 sex 130 age 131-132/*
	*/ education 133 party 151 partyln 152 ideology 153/*
	*/ regist 149 llweight 169-173 coweight 174-178/*
	*/ q37a_d 95 q37b_d 96 q37c_d 97 q37d_d 98 /*
	*/ q37f_d 99 q37g_d 100 q37h_d 101 q37j_d 102/*
	*/ q37k_d 103 q37l_d 104 q37m_d 105 q37n_d 106/*
	*/ q45_f 114/*
	*/ hispanic 134 race 140 income 147-148 /*
	*/ using Pew/uspew2011-05pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-05pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q37a_d q37b_d q37c_d q37d_d q37f_d q37g_d q37h_d  q37j_d q37k_d q37l_d q37m_d q37n_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q45_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 165-169 rid 1-6 sex 118 age 119-120/*
	*/ education 121 party 138 partyln 139 ideology 140/*
	*/ regist 136 llweight 155-159 coweight 160-164/*
	*/ q18_f 59 q31_d 61 q56_d 93 q57_d 94 q72_f 99/*
	*/ q75_f 102 q79_d 105/*
	*/ hispanic 122 race 128 income 134-135 /*
	*/ using Pew/uspew2011-06pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-06pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q18_f q31_d q72_f q75_f q79_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q56_d q57_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 204-208 rid 1-6 sex 156 age 157-158/*
	*/ education 159 party 176 partyln 177 ideology 178/*
	*/ regist 174 llweight 194-198 coweight 199-203/*
	*/ q24_d 84 /*
	*/ hispanic 160 race 166 income 172-173 /*
	*/ using Pew/uspew2011-07pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-07pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q24_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-08pol
{
clear
infix 1 lines 1: pollmethod 7 weight 179-283 rid 1-6 sex 127 age 128-129/*
	*/ education 130 party 148 partyln 149 ideology 152/*
	*/ regist 146 vote2008 154 llweight 174-178 coweight 169-173/*
	*/ q35_d 102 q77a_d 118 q77b_d 119 q77d_d 120 q77e_d 121 q81_f 124/*
	*/ hispanic 131 race 138 income 144-145 /*
	*/ using Pew/uspew2011-08pol.dat

tab pollmethod 
gen survey="uspew2011-08pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q35_d q77a_d q77b_d q77d_d q77e_d q81_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-09gen
{
clear
infix 1 lines 1: pollmethod 7 weight 173-177 rid 1-6 sex 123 age 124-125/*
	*/ education 126 party 146 partyln 147 ideology 148/*
	*/ regist 144 vote2008 150 llweight 163-167 coweight 168-172/*
	*/ q8_d 48 q69a_d 93 q69b_d 94 q69c_f 95 q70_d 96/*
	*/ q77_d 98 q78_d 99 q79a_d 100 q79b_d 101 q79c_d 102/*
	*/ q80a_d 103 q80b_d 104 q80c_d 105/*
	*/ hispanic 127 race 133 income 141-142 /*
	*/ using Pew/uspew2011-09gen.dat

tab pollmethod 
gen survey="uspew2011-09gen"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q69a_d q69b_d q69c_f q70_d q79a_d q79b_d q79c_d q80a_d q80b_d q80c_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}


local vars_2 q8_d q77_d q78_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-11pol
{
clear
infix 1 lines 1: pollmethod 7 weight 201-205 rid 1-6 sex 161 age 162-163/*
	*/ education 164 party 176 partyln 177 ideology 178/*
	*/ regist 58 llweight 191-195 coweight 196-200/*
	*/ q40_d 105 q56_f 123 q58_f 125 q68_d 130 /*
	*/ q71_d 141 q72_d 142 q73_d 143 /*
	*/ hispanic 165 race 172 income 174-175 /*
	*/ using Pew/uspew2011-11pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-11pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q40_d q56_f q58_f q68_d q71_d q73_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q72_d 
foreach var of varlist `vars_2' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 121 age 122-123/*
	*/ education 124 party 65 partyln 66 ideology 140/*
	*/ regist 61 llweight 159-163 coweight 154-158/*
	*/ q36a_f 94 q36b_f 95 q36c_d 96 q36d_d 97 q36e_d 98/*
	*/ q44e_d 105 q45_d 106 q49_d 117 q52_d 120/*
	*/ hispanic 125 race 132 income 138-139 /*
	*/ using Pew/uspew2011-12pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q36a_f q36b_f q36c_d q36d_d q36e_d q45_d q49_d q52_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q44e_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2011-sdt09
{
clear
infix 1 lines 1: pollmethod 7 weight 199-203 rid 1-6 sex 37 age 55-56/*
	*/ education 140 party 155 partyln 156 ideology 157/*
	*/ regist 153 /*
	*/ q31_f 115 q32_f 116 q33_f 117 q34_f 118 q35_f 119/*
	*/ hispanic 141 race 174 income 151-152 /*
	*/ using Pew/uspew2011-sdt09.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-sdt09"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q31_f q32_f q33_f q34_f q35_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-01com
{
clear
infix 1 lines 1: pollmethod 7 weight 185-189 rid 1-6 sex 43 age 141-142/*
	*/ education 143 party 161 partyln 162 ideology 163/*
	*/ regist 97 llweight 175-179 coweight 180-184 /*
	*/ q17a_d 57 q17b_d 58 q17c_d 59 q19_d 62/*
	*/ hispanic 144 race 150 income 159-160 /*
	*/ using Pew/uspew2012-01com.dat

recode education (8=7)	
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-01com"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q17a_d q17b_d q17c_d q19_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 212-215 rid 1-6 sex 170 age 171-172/*
	*/ education 173 party 70 partyln 71 ideology 190/*
	*/ regist 68 llweight 201-205 coweight 206-210 /*
	*/ q43_f 145 q65_f 167 q69_f 169/*
	*/ hispanic 174 race 181 income 188-189 /*
	*/ using Pew/uspew2012-01pol.dat
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q43_f q65_f q69_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 185-189 rid 1-6 sex 139 age 140-141/*
	*/ education 142 party 159 partyln 160 ideology 162/*
	*/ regist 67 llweight 175-179 coweight 180-184 /*
	*/ q43_d 112 q57_f 120 q60_f 121 q61_f 122 q71_d 137/*
	*/ hispanic 143 race 149 income 157-158 /*
	*/ using Pew/uspew2012-02pol.dat

recode education (8=7)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* vote2008	
tab pollmethod 
gen survey="uspew2012-02pol"

local vars_1 q61_f q71_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q43_d q57_f q60_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-03pol
{
clear
infix 1 lines 1: pollmethod 7 weight 184-188 rid 1-6 sex 137 age 138-139/*
	*/ education 140 party 156 partyln 157 ideology 158/*
	*/ regist 67 llweight 169-173 coweight 174-178 /*
	*/ q39_f 99 q42_f 100 q43a_d 101 q43b_d 102 q43c_d 103/*
	*/ q43d_d 104 q43e_d 105 q43f_d 106 q45_d 108 q65_f 127/*
	*/ q66_f 128 q67_f 129 q74_d 134/*
	*/ q75_d 135 q76_d 136/*
	*/ hispanic 141 race 147 income 154-155 /*
	*/ using Pew/uspew2012-03pol.dat

recode education (8=7)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
* vote2008	
tab pollmethod 
gen survey="uspew2012-03pol"

local vars_1 q39_f q42_f q43a_d q43b_d q43c_d q43d_d q43e_d q43f_d q45_d q65_f q66_f q67_f q74_d q75_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q76_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 216-220 rid 1-6 sex 157 age 158-159/*
	*/ education 160 party 186 partyln 187 ideology 189/*
	*/ regist 64 vote2008 191 llweight 206-210 coweight 211-215 /*
	*/ q54_d 143 q66_d 154 q67_d 155 q68_d 156/*
	*/ hispanic 161 race 175 news_scourthealth 58 news_elections 59 news_econ 60 /*
	*/ income 184-185 /*
	*/ using Pew/uspew2012-06pol.dat

recode education (8=7)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-06pol"

local vars_1 q54_d q66_d q68_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_3 q67_d
foreach var of varlist `vars_3' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-09pol
{
clear
infix 1 lines 1: pollmethod 7 weight 251-255 rid 1-6 sex 168 age 169-170/*
	*/ education 171 party 197 partyln 198 ideology 199/*
	*/ regist 51 vote2008 201 llweight 246-250 coweight 241-245 /*
	*/ q39_d 156 q40_d 157 q41_d 158/*
	*/ q49a_d 162 q49b_d 163 q49c_f 164 q49d_d 165 q49e_d 166 q49f_d 167/*
	*/ hispanic 172 race 187 news_elections 50 /*
	*/ income 195-196 /*
	*/ using Pew/uspew2012-09pol.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-09pol"

local vars_1 q39_d q41_d q49a_d q49b_d q49c_f q49d_d q49e_d q49f_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q40_d 
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-10ear
{
clear
infix 1 lines 1: pollmethod 7 weight 198-202 rid 1-6 sex 126 age 127-128/*
	*/ education 129 party 145 partyln 146 ideology 148/*
	*/ regist 49 vote2008 150 llweight 172-176 coweight 177-181 /*
	*/ q35a_d 85 q35b_d 86 q35c_d 87 q35d_d 88/*
	*/ q35f_d 89 q35g_d 90 q35h_d 91 q35i_d 92 q35j_d 93/*
	*/ q35k_d 94 q35m_d 95 q35n_d 96 q39_f 97 q42_f 99/*
	*/ q52_f 101 q56_f 102 q59_f 105 q60_f 106/*
	*/ hispanic 130 race 136 news_elections 48 income 143-144 /*
	*/ using Pew/uspew2012-10ear.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-10ear"

local vars_1 q35a_d q35b_d q35c_d q35d_d q35f_d q35g_d q35h_d q35i_d q35j_d q35k_d q35m_d q35n_d q39_f q42_f q56_f q59_f q60_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q52_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-10late
{
clear
infix 1 lines 1: pollmethod 7 weight 286-290 rid 1-6 sex 141 age 142-143/*
	*/ education 144 party 171 partyln 172 ideology 173/*
	*/ regist 49 vote2008 174 llweight 271-275 coweight 276-280 /*
	*/ q45_d 131 q46_d 132 q55_d 137/*
	*/ hispanic 145 race 151 news_elections 48 income 169-170 /*
	*/ using Pew/uspew2012-10late.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-10late"

local vars_1 q45_d q46_d q55_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2012-12gun
{
clear
infix 1 lines 1: pollmethod 7 weight 114-118 rid 1-6 sex 72 age 73-74/*
	*/ education 77 party 87 partyln 88 ideology 89/*
	*/ llweight 104-108 coweight 99-103 /*
	*/ q3_d 52 q7_d 63 q8_d 64/*
	*/ q9a_d 65 q9b_d 66 q9c_d 67 q9d_d 68 q12_d 70/*
	*/ hispanic 79 race 85/*
	*/ using Pew/uspew2012-12gun.dat

* regist vote2008
recode education (8=7)	
* recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2012-12gun"

local vars_1 q3_d q7_d q8_d q9a_d q9b_d q9c_d q9d_d q12_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2012-12pol
{
clear
infix 1 lines 1: pollmethod 9 weight 213-222 rid 1-8 sex 146 age 147-148/*
	*/ education 149 party 169 partyln 170 ideology 171/*
	*/ regist 168 llweight 193-202 coweight 203-212 /*
	*/ q6_d 65 q43_d 102 q47a_d 104 q47b_d 105 q47c_d 106/*
	*/ q47d_d 107 q47e_d 108 q47f_d 109 q47g_d 110 q47h_d 111/*
	*/ q47i_d 112 q47j_d 113 q47k_d 114 q47l_d 115 q60_f 120/*
	*/ q65_f 122 q66_f 123/*
	*/ hispanic 150 race 162-163 income 164-165 /*
	*/ using Pew/uspew2012-12pol.dat

*  vote2008
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-12pol"

local vars_1 q6_d q43_d q47a_d q47b_d q47c_d q47d_d q47e_d q47f_d q47g_d q47h_d q47i_d q47j_d q47k_d q47l_d q65_f q66_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q60_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2012-relig
{
clear
infix 1 lines 1: pollmethod 7 weight 208-212 rid 1-6 sex 155 age 156-157/*
	*/ education 158 party 173 partyln 174 ideology 176/*
	*/ reg 64 regist 63 llweight 198-202 coweight 193-197 /*
	*/ q24_f 99 q26_d 101 q30a_d 102 q30b_d 103/*
	*/ hispanic 159 race 167 income 171-172 /*
	*/ using Pew/uspew2012-relig.dat

*  vote2008
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
replace regist=reg if missing(regist)
drop reg
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-relig"

local vars_1 q24_f q26_d q30a_d q30b_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2012-sdt12
{
clear
infix 1 lines 1: pollmethod 7 weight 201-205 rid 1-6 sex 46 age 58-59/*
	*/ education 135 party 155 partyln 156 ideology 157/*
	*/ regist 152 vote2012 153 /*
	*/ q31_d 99 q34a_d 102 q34b_d 103 q34c_d 104/*
	*/ q35a_d 105 q35b_d 106/*
	*/ hispanic 136 race 170/*
	*/ income 150-151 /*
	*/ using Pew/uspew2012-sdt12.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-sdt12"

local vars_1 q34a_d q34b_d q34c_d q35a_d q35b_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q31_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2012-values
{
clear
infix 1 lines 1: pollmethod 28 weight 300-304 rid 1-6 sex 247 age 248-249/*
	*/ education 250 party 147 partyln 149 ideology 152/*
	*/ reg 61 regist 60 /*
	*/ q18_f 112 q20_d 114 q21_d 115 q30i_d 125 q30j_d 126 q30l_d 128/*
	*/ q30o_d 131 q30v_d 138 q30bb_d 143 q40a_d 177 q40d_d 180/*
	*/ q40e_d 181 q40f_d 182 q40g_d 183 q40k_d 187 q40l_d 188/*
	*/ q40n_d 190 q40o_f 191 q40p_f 192 q40u_f 196 q40x_d 198/*
	*/ q40z_d 199 q40aa_d 200 q40ee_d 201 q41e_d 206 q41f_d 207/*
	*/ q41g_d 208 q41h_d 209 q41i_d 210 q41j_d 211 q41o_d 214/*
	*/ q41p_d 215 q41gg_d 224 q41hh_d 225/*
	*/ hispanic 251 race 261 income 272-273 /*
	*/ using Pew/uspew2012-values.dat

* q30v_d = q30v1	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
replace regist=reg if missing(regist)
drop reg
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2012-values"

local vars_1 q18_f q20_d q21_d q30i_d q30j_d q30l_d q30o_d q30v_d q30bb_d q40a_d  q40d_d q40e_d q40f_d q40g_d q40k_d q40l_d q40n_d q40o_f q40p_f q40u_f q40x_d q40z_d q40aa_d q40ee_d q41e_d q41f_d q41g_d q41h_d q41i_d q41j_d q41o_d q41p_d q41gg_d q41hh_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2013-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 189-193 rid 1-6 sex 134 age 135-136/*
	*/ education 139 party 159 partyln 160 ideology 161/*
	*/ regist 158 llweight 179-183 coweight 174-178/*
	*/ q40_d 115 q42a_d 117 q42b_d 118 q42c_d 119 q42d_d 120/*
	*/ q42e_d 121 q42f_d 122 q42g_d 123 q42h_d 124 q42i_d 125 q53_d 132/*
	*/ hispanic 141 race 147 income 156-157 /*
	*/ using Pew/uspew2013-01pol.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-01pol"

local vars_1 q40_d q42a_d q42b_d q42c_d q42d_d q42e_d q42f_d q42g_d q42h_d q42i_d q53_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2013-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 220-224 rid 1-6 sex 168 age 169-170/*
	*/ education 173 party 188 partyln 189 ideology 191/*
	*/ regist 187 llweight 210-214 coweight 205-209/*
	*/ q15_d 70 q17_d 72 q18a_d 73 q18b_d 74 q19_d 75/*
	*/ q20a_d 76 q20b_d 77 q20c_d 78 q23_d 85/*
	*/ q28a_d 86 q28b_d 87 q28c_f 88 q28d_d 89 q28e_d 90/*
	*/ q28f_f 91 q28g_d 92 q28h_d 93 q28i_d 94 q28j_d 95/*
	*/ q28k_f 96 q28l_d 97 q28m_d 98 q28n_d 99 q28o_d 100/*
	*/ q28p_d 101 q28q_f 102 q28r_d 103 q28s_d 104/*
	*/ hispanic 175 race 181 income 185-186 /*
	*/ using Pew/uspew2013-02pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-02pol"

local vars_1 q18a_d q18b_d q19_d q20a_d q20b_d q20c_d q23_d q28a_d q28b_d q28c_f q28d_d q28e_d q28f_f q28g_d q28h_d q28i_d q28j_d q28k_f q28l_d q28m_d q28n_d q28o_d q28p_d q28q_f q28r_d q28s_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q17_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

local vars_3 q15_d
foreach var of varlist `vars_3' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2013-03pol
{
clear
infix 1 lines 1: pollmethod 9 weight 201-210 rid 1-8 sex 163 age 164-165/*
	*/ education 166 party 188 partyln 189 ideology 190/*
	*/ regist 187 llweight 211-220 coweight 221-230/*
	*/ q6_d 73 q7_d 74 q15a_d 75 q15b_d 76 q15c_d 77 q15e_d 78/*
	*/ q56_d 113 q61_d 115 q70_f 130 q73_f 132 q77a_d 133 q77b_d 134/*
	*/ q85_d 135 q89_d 140 /*
	*/ hispanic 167 race 178-179 income 185-186 /*
	*/ using Pew/uspew2013-03pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-03pol"

local vars_1 q56_d q61_d q77a_d q77b_d q85_d q89_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q6_d q7_d q15a_d q15b_d q15c_d q15e_d q70_f q73_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2013-05pol
{
clear
infix 1 lines 1: pollmethod 7 weight 214-218 rid 1-6 sex 150 age 151-152/*
	*/ education 155 party 182 partyln 183 ideology 184/*
	*/ regist 181 llweight 204-208 coweight 199-203/*
	*/ q17a_d 78 q17b_d 79 q25_d 87 q27_d 89 q36a_d 92 q36b_d 93/*
	*/ q40_d 98 q46a_d 101 q46b_d 102 q46c_d 103 q46d_d 104/*
	*/ hispanic 157 race 163 income 179-180 /*
	*/ using Pew/uspew2013-05pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-05pol"

local vars_1 q25_d q27_d q36a_d q36b_d q40_d q46a_d q46b_d q46c_d q46d_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q17a_d q17b_d 
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}

*** uspew2013-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 115 age 116-117/*
	*/ education 120 party 134 partyln 135 ideology 136/*
	*/ regist 133 llweight 154-158 coweight 149-153/*
	*/ q15_f 66 q16a_f 67 q16b_f 68 q16c_f 69 q16d_f 70 q37_d 82 q46_d 90/*
	*/ q47b_d 91 q47c_d 92 q47d_d 93 q48_d 94 /*
	*/ q55a_d 98 q55b_d 99 q55c_d 100 q55d_d 101 q55e_d 102 q55f_d 103 q55g_d 104/*
	*/ q56_d 105/*
	*/ hispanic 122 race 129 income 130-131 /*
	*/ using Pew/uspew2013-06pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-06pol"

local vars_1 q15_f q16a_f q16b_f q16c_f q16d_f q37_d q46_d q47b_d q47c_d q47d_d q48_d q55a_d q55b_d q55c_d q55d_d q55e_d q55f_d q55g_d q56_d 
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 194-198 rid 1-6 sex 146 age 147-148/*
	*/ education 151 party 115 partyln 116 ideology 169/*
	*/ regist 168 vote2012 171 llweight 189-193 coweight 184-188/*
	*/ q10_d 58 q21_d 70 q40_d 85/*
	*/ hispanic 153 race 160 income 166-167 /*
	*/ using Pew/uspew2013-07pol.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-07pol"

local vars_1 q21_d q40_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}
local vars_2 q10_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-09pol
{
clear
infix 1 lines 1: pollmethod 7 weight 169-173 rid 1-6 sex 116 age 117-118/*
	*/ education 121 party 139 partyln 140 ideology 141/*
	*/ regist 138 llweight 159-163 coweight 154-158/*
	*/ q5_f 53 q8a_f 58 q8b_f 59 q8c_f 60 q8d_f 61 q8e_f 62 q8f_f 63/*
	*/ q10_d 64 q15_d 65 q41_d 81 q55a_d 92 q55b_d 93/*
	*/ q55c_d 94 q55e_d 95 q55f_d 96 q56a_d 97 q56b_d 98 q56c_d 99/*
	*/ q65_d 105/*
	*/ hispanic 123 race 130 income 136-137 /*
	*/ using Pew/uspew2013-09pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode q65_d (1 2 4=1) (3 9=0)
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-09pol"

local vars_1 q5_f q8a_f q8b_f q8c_f q8d_f q8e_f q8f_f q41_d q55a_d q55b_d q55c_d q55e_d q55f_d q56a_d q56b_d q56c_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}
local vars_2 q10_d q15_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 198-207 rid 1-6 sex 127 age 128-129/*
	*/ education 130 party 152 partyln 153 ideology 154/*
	*/ regist 151 llweight 178-187 coweight 188-197/*
	*/ q36_d 84/*
	*/ hispanic 131 race 142 income 149-150 /*
	*/ using Pew/uspew2013-10pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-10pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q36_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-11apw
{
clear
infix 1 lines 1: pollmethod 7 weight 214-218 rid 1-6 sex 162 age 163-164/*
	*/ education 167 party 186 partyln 187 ideology 188/*
	*/ regist 185 llweight 209-213 coweight 204-208/*
	*/ q17_d 96 q20_d 103 q24_f 105 q26_f 107 q28_f 108 q31_f 116/*
	*/ q32a_f 117 q32b_f 118 q32c_f 119 q32d_f 120/*
	*/ q32e_f 121 q32f_f 122 q32i_f 123 q32j_f 124/*
	*/ q33a_f 125 q33b_f 126 q33c_f 127 q33d_f 128 q33e_f 129 /*
	*/ q33f_f 130 q33g_f 131 q33h_f 132 q33i_f 133 q33j_f 134 q33k_f 135/*
	*/ q34_f 136 q40_f 137 q41_f 138 q42_f 139 q43_f 140 q44_f 141 q46_f 142/*
	*/ q49a_d 145 q49c_d 146 q49d_d 147 q49e_d 148 q49f_d 149/*
	*/ q50_f 150 q51_f 151 q52_f 152 q57_d 157/*
	*/ hispanic 169 race 175 income 183-184 /*
	*/ using Pew/uspew2013-11apw.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-11apw"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q17_d q24_f q26_f q28_f q32a_f q32b_f q32c_f q32d_f q32e_f q32f_f q32i_f q32j_f q33a_f q33b_f q33c_f q33d_f q33e_f q33f_f q33g_f q33h_f q33i_f q33j_f q33k_f q34_f q40_f q41_f q42_f q43_f q44_f q46_f q49a_d q49c_d q49d_d q49e_d q49f_d q50_f q51_f q52_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q20_d q31_f q57_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 219-223 rid 1-6 sex 156 age 157-158/*
	*/ education 161 party 181 partyln 182 ideology 190/*
	*/ regist 180 llweight 209-213 coweight 204-208/*
	*/ q31_d 75 q33_d 76 q34_d 77 q35_d 78 q36_d 79 q68_f 98/*
	*/ q70b_d 101 q70c_d 102 q70e_f 104 /*
	*/ hispanic 163 race 169 income 178-179 /*
	*/ using Pew/uspew2013-12pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q31_d q33_d q68_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q34_d q35_d q36_d q70b_d q70c_d q70e_f 
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0124
{
clear
infix 1 lines 1: pollmethod 7 weight 52-56 rid 1-6 sex 37 age 38-39/*
	*/ education 41 party 50 partyln 51/*
	*/ regist 49 /*
	*/ q1_d 26/*
	*/ hispanic 43 race 45 news_deficit 19 news_benghazi 20 news_weather 21 /*
	*/ news_obama 22 news_womencombat 23 income 46-47 /*
	*/ using Pew/uspew2013-wk0124.dat

* q1_d = pewwp1	
* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0124"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q1_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0207
{
clear
infix 1 lines 1: pollmethod 7 weight 49-53 rid 1-6 sex 34 age 35-36/*
	*/ education 38 party 47 partyln 48/*
	*/ regist 46 /*
	*/ q9_f 23 /*
	*/ hispanic 40 race 42 income 43-44 /*
	*/ using Pew/uspew2013-wk0207.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0207"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q9_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0314
{
clear
infix 1 lines 1: pollmethod 7 weight 56-60 rid 1-6 sex 41 age 42-43/*
	*/ education 45 party 54 partyln 55/*
	*/ regist 53 /*
	*/ q9_f 31 /*
	*/ hispanic 47 race 49 news_econ 19 news_deficit 20 /*
	*/ news_pope 21 news_afghan 22 income 50-51 /*
	*/ using Pew/uspew2013-wk0314.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
tab pollmethod 
gen survey="uspew2013-wk0314"

local vars_1 q9_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0606
{
clear
infix 1 lines 1: pollmethod 7 weight 81-85 rid 1-6 sex 66 age 67-68/*
	*/ education 70 party 79 partyln 80/*
	*/ regist 78 /*
	*/ q3_d 49 q4_d 56 /*
	*/ hispanic 72 race 74 news_econ 23 news_immigration 24 news_sxasmil 25 /*
	*/ news_turkey 26 news_syria 27 news_wiretaps 28 news_emailtaps 29 /*
	*/ income 75-76 /*
	*/ using Pew/uspew2013-wk0606.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0606"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q3_d q4_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0829
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 43 party 52 partyln 53/*
	*/ regist 51 /*
	*/ q2_f 26 q6_f 31/*
	*/ hispanic 45 race 47 news_syria 21 news_fire 22 news_health 23 news_mlk 24 /*
	*/ news_nfl 25 income 48-49 /*
	*/ using Pew/uspew2013-wk0829.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0829"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)

local vars_1 q6_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q2_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk0912
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 42 party 49 partyln 50/*
	*/ regist 48 /*
	*/ q4_f 30/*
	*/ hispanic 43 race 53 news_syria 19 news_wiretaps 20 news_econ 21 news_apple 22 /*
	*/ income 45-46 /*
	*/ using Pew/uspew2013-wk0912.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0912"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q4_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk1003
{
clear
infix 1 lines 1: pollmethod 7 weight 58-62 rid 1-6 sex 41 age 42-43/*
	*/ education 44 party 51 partyln 52/*
	*/ regist 50 ideology 53/*
	*/ q18_d 33/*
	*/ hispanic 45 race 57 news_govshut 19 news_health 20 news_econ 21 /*
	*/ income 47-48 /*
	*/ using Pew/uspew2013-wk1003.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk1003"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q18_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2013-wk1031
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 42 party 49 partyln 50/*
	*/ regist 48 /*
	*/ q2a_f 23 q2b_f 24 q2c_f 25 q2d_f 26 q2e_d 27 q7_f 32/*
	*/ hispanic 43 race 53 /*
	*/ news_health 19 news_wiretaps 20 news_econ 21 news_baseball 22 /*
	*/ income 45-46 /*
	*/ using Pew/uspew2013-wk1031.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk1031"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q2a_f q2b_f q2c_f q2d_f q2e_d q7_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014_02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 184-188 rid 1-6 sex 141 age 65-66/*
	*/ education 142 party 156 partyln 157/*
	*/ regist 155 ideology 158 llweight 174-178 coweight 179-183/*
	*/ q24_d 73 q30_d 75 q39_d 79/*
	*/ hispanic 143 race 150 income 152-153 /*
	*/ using Pew/uspew2014_02pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014_02pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q24_d q30_d q39_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 234-238 rid 1-6 sex 167 age 168-169/*
	*/ education 170 party 190 partyln 191/*
	*/ regist 189 ideology 199 llweight 219-223 coweight 214-218/*
	*/ q27_d 102 q30_d 105 q35_f 119 q37_f 121 q44b_d 126/*
	*/ q44c_d 127 q44d_d 128 q46a_d 151 q46b_d 152/*
	*/ hispanic 171 race 178 income 187-188 /*
	*/ using Pew/uspew2014-01pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q27_d q30_d q35_f q37_f q46a_d q46b_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q44b_d q44c_d q44d_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 181-185 rid 1-6 sex 135 age 136-137/*
	*/ education 138 party 156 partyln 157/*
	*/ regist 155 ideology 158 llweight 171-175 coweight 176-180/*
	*/ q50_f 111 q77a_f 132 q77b_f 133/*
	*/ hispanic 139 race 145 income 153-154 /*
	*/ using Pew/uspew2014-04pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-04pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q77a_f q77b_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q50_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 168-172 rid 1-6 sex 118 age 119-120/*
	*/ education 121 party 136 partyln 137/*
	*/ regist 135 ideology 140 llweight 158-162 coweight 163-167/*
	*/ q53_f 98 q55_d 100 q60_f 103/*
	*/ hispanic 122 race 155 news_elections 53 income 133-134 /*
	*/ using Pew/uspew2014-07pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-07pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q55_d q60_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q53_f 
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-08pol
{
clear
infix 1 lines 1: pollmethod 7 weight 182-191 rid 1-6 sex 123 age 124-125/*
	*/ education 126 party 150 partyln 151/*
	*/ regist 149 ideology 154 llweight 162-171 coweight 172-181/*
	*/ q52_f 95 q54a_f 96 q54b_f 97 q54c_f 98 q54d_f 99 q54e_f 100/*
	*/ q54f_f 101 q54g_f 102 q54h_f 103 q54i_f 104 q60a_f 105/*
	*/ q60b_f 106 q66_d 109/*
	*/ q69a_d 110 q69b_d 111 q69c_d 112 q70_d 113/*
	*/ hispanic 127 race 138 income 147-148 /*
	*/ using Pew/uspew2014-08pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-08pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q52_f q54a_f q54b_f q54c_f q54d_f q54e_f q54f_f q54g_f q54h_f q54i_f q60a_f q60b_f q69a_d q69b_d q69c_d q70_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q66_d
foreach var of varlist `vars_2' {
recode `var' (1/3=1) (4/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-09rel
{
clear
infix 1 lines 1: pollmethod 7 weight 202-206 rid 1-6 sex 105 age 106-107/*
	*/ education 108 party 130 partyln 131/*
	*/ regist 129 ideology 132 vote2012 150 llweight 192-196 coweight 197-201/*
	*/ q14_d 72 q16_d 74 q18_d 75 q19_d 76/*
	*/ hispanic 109 race 116 income 127-128 /*
	*/ using Pew/uspew2014-09rel.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-09rel"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q18_d q19_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q14_d q16_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 204-208 rid 1-6 sex 136 age 137-138/*
	*/ education 139 party 155 partyln 156/*
	*/ regist 54 ideology 157 vote2012 159 llweight 194-198 coweight 199-203/*
	*/ q70_d 121 q72_d 123 q75_f 125 q77_f 127/*
	*/ q79_f 129 q80_f 130 q87_f 135/*
	*/ hispanic 140 race 146 news_elections 55 income 153-154 /*
	*/ using Pew/uspew2014-10pol.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-10pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q70_d q72_d q75_f q79_f q80_f q87_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q77_f
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-11post
{
clear
infix 1 lines 1: pollmethod 7 weight 151-155 rid 1-6 sex 107 age 108-109/*
	*/ education 110 party 127 partyln 128/*
	*/ regist 53 ideology 131 llweight 141-145 coweight 146-150/*
	*/ q38_d 81 q69a_f 103 q69b_f 104 q69c_f 105/*
	*/ hispanic 111 race 117/*
	*/ news_isis 49 news_ebola 50 news_elections 51 news_econ 52 income 125-126 /*
	*/ using Pew/uspew2014-11post.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-11post"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q38_d q69a_f q69b_f q69c_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 120 age 121-122/*
	*/ education 123 party 142 partyln 143/*
	*/ regist 141 ideology 144 llweight 154-158 coweight 159-163/*
	*/ q53_d 87 q70_d 96/*
	*/ hispanic 124 race 130 income 139-140 /*
	*/ using Pew/uspew2014-12pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-12pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q53_d q70_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace
}
*** uspew2014-typo
{
clear
infix 1 lines 1: pollmethod 12 weight 323-330 rid 1-6 sex 221 age 222-223/*
	*/ education 224 party 249 partyln 250 ideology 255 /*
	*/ regist 248 vote2012 266 llweight 294-303 coweight 304-313/*
	*/ q25b_d 88 q25c_d 89 q25d_d 90 q25f_d 91 q25g_d 92/*
	*/ q25i_f 94 q25m_d 98 q25n_d 99/*
	*/ q50q_d 146 q50r_d 147 q50u_d 150 q50v_d 151 q50bb_f 156/*
	*/ q50dd_d 157 q50ee_f 158 q50ff_d 159 q50gg_d 160 q50hh_d 161/*
	*/ q51ii_d 162 q51kk_d 164 q51ll_d 165 q51oo_d 167 /*
	*/ q106_d 183 q107_d 185 q108_d 186 q110_d 188 q115_f 191/*
	*/ q121_d 195 q122_d 198 q123_d 201 q124_d 204 q125_d 207/*
	*/ q126_d 210 q127_d 213 q128_d 214/*
	*/ hispanic 225 race 291 income 245-246 /*
	*/ using Pew/uspew2014-typo.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-typo"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q106_d q108_d q110_d q115_f q121_d q122_d q123_d q124_d q125_d q126_d q127_d q128_d
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q25b_d q25c_d q25d_d q25f_d q25g_d q25i_f q25m_d q25n_d q50q_d q50r_d q50u_d q50v_d q50bb_f q50dd_d q50ee_f q50ff_d q50gg_d q50hh_d q51ii_d q51kk_d q51ll_d q51oo_d q107_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}

*** uspew2014-wk0306
{
clear
infix 1 lines 1: pollmethod 7 weight 54-59 rid 1-6 sex 33 age 34-35/*
	*/ education 36 party 41 partyln 42 /*
	*/ regist 27 /*
	*/ q5_f 23 q8_f 24/*
	*/ hispanic 37 race 53/*
	*/ news_econ 17 news_ukraine 18 news_budget 19 news_sat 20 news_health 21 /*
	*/ income 39-40 /*
	*/ using Pew/uspew2014-wk0306.dat
	
* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0306"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q5_f q8_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}

*** uspew2014-wk0320
{
clear
infix 1 lines 1: pollmethod 7 weight 59-64 rid 1-6 sex 43 age 44-45/*
	*/ education 46 party 53 partyln 54 /*
	*/ regist 52 ideology 55/*
	*/ q3_f 32 q4_f 33 q6_f 35/*
	*/ hispanic 47 race 58/*
	*/ news_econ 20 news_ukraine 21 news_ma370 22 news_wiretaps 23 news_elections 24 /*
	*/ news_health 25 news_toyota 26 income 49-50 /*
	*/ using Pew/uspew2014-wk0320.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0320"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q3_f q4_f q6_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}

*** uspew2014-wk0605
{
clear
infix 1 lines 1: pollmethod 7 weight 52-56 rid 1-6 sex 35 age 36-37/*
	*/ education 38 party 45 partyln 46 /*
	*/ regist 44 ideology 47/*
	*/ q6_f 27/*
	*/ hispanic 39 race 51/*
	*/ news_bowebergdahl 20 news_powerplants 21 news_elections 22 /*
	*/ news_econ 23 news_veterans 24 income 41-42 /*
	*/ using Pew/uspew2014-wk0605.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0605"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q6_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}

*** uspew2014-wk0724
{
clear
infix 1 lines 1: pollmethod 7 weight 51-55 rid 1-6 sex 35 age 36-37/*
	*/ education 38 party 45 partyln 46 /*
	*/ regist 44 ideology 47/*
	*/ q4_f 25 q5_f 26 q6_f 27 q7_f 28/*
	*/ hispanic 39 race 50 news_israel 20 news_ma370 21 news_usborder 22 /*
	*/ news_health 23 news_elections 24 income 41-42 /*
	*/ using Pew/uspew2014-wk0724.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0724"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q4_f q5_f q6_f q7_f
foreach var of varlist `vars_1' {
recode `var' (1/7=1) (8/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}

*** uspew2014-wk0814
{
clear
infix 1 lines 1: pollmethod 7 weight 53-57 rid 1-6 sex 37 age 38-39/*
	*/ education 40 party 47 partyln 48 /*
	*/ regist 46 ideology 49/*
	*/ q2_f 25 q3_f 26 q5_f 27 q7_d 29/*
	*/ hispanic 41 race 52/*
	*/ news_isis 20 news_robinwilliams 21 news_ferguson 22 news_ebola 23 /*
	*/ news_ukraine 24 income 43-44 /*
	*/ using Pew/uspew2014-wk0814.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0814"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_2 q2_f q3_f q5_f q7_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}
*** uspew2015-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 170-174 rid 1-6 sex 121 age 122-123/*
	*/ education 124 party 141 partyln 142 /*
	*/ regist 140 ideology 145 llweight 160-164 coweight 165-169/*
	*/ q51_f 112 q54_f 113 q63_d 117 q65_d 119 q66_f 120/*
	*/ hispanic 125 race 131 income 138-139 /*
	*/ using Pew/uspew2015-01pol.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2015-01pol"
recode income (1/2=1) (3/4=2) (5=3) (6/7=4) (8/9=5) (else=.)
local vars_1 q66_f
foreach var of varlist `vars_1' {
recode `var' (1/8=1) (9=0)
}

local vars_2 q51_f q54_f q63_d q65_d
foreach var of varlist `vars_2' {
recode `var' (1/2=1) (3/9=0)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR.dta
saveold SNR.dta, replace	
}
}
********************************
*** prepare variables
********************************
{
clear
use SNR.dta, clear
drop if missing(response)
saveold SNR.dta, replace	

clear
use SNR.dta, clear
recode vote2000 (1/6=1) (7=2) (8/9=3)
gen VOTE=.
replace VOTE=vote2000 if missing(VOTE)
replace VOTE=vote2004 if missing(VOTE)
replace VOTE=vote2008 if missing(VOTE)
replace VOTE=vote2012 if missing(VOTE)
label define vote 1 "1. yes" 2 "2. no" 3 "3. dk"

foreach var of varlist VOTE vote2000 vote2004 vote2008 vote2012{
label values `var' vote
}

label variable VOTE "voted in last presidential election"
label variable vote2000 "voted in 2000 presidential election"
label variable vote2004 "voted in 2004 presidential election"
label variable vote2008 "voted in 2008 presidential election"
label variable vote2012 "voted in 2012 presidential election"
label define age 97 "97 or older" 99 "99. refused"
label values age age
label variable age "respondent age"
label variable rid "respondent unique id per survey"
label define pollmethod 1 "1. landline" 2 "2. cell"
label values pollmethod pollmethod
label variable pollmethod "polling method: landline vs. cell per respondent"
label variable weight "overall weight variable"
label variable sex "respondent sex"
label define sex 1 "1. male" 2 "2. female"
label values sex sex
recode education (8=9)
label define education 1 "1. none/1-8" 2 "2. 9-11 years" 3 "3. high school grad"/*
	*/ 4 "4. business/nursing, etc." 5 "5. some collage" 6 "6. collage grad" /*
	*/ 7 "7. ma /phd/post" 9 "9. dk/refused"
label values education education
label variable education "respondent education"
recode party (3/5=3) (8=9)
label define party 1 "1. Republican" 2 "2. Democrat" 3 "3. Independent/Other" 9 "9. dk"
label values party party
label variable party "respondent party"
recode partyln (7/8=9)
label define partyln 1 "1. Republican" 2 "2. Democrat" 9 "9. Independent/Other/dk"
label values partyln partyln
label variable partyln "respondent lean to party if party=independent/dk"
gen PARTY5=1 if party==1
replace PARTY5=5 if party==2
replace PARTY5=2 if partyln==1 & inrange(party,3,9)
replace PARTY5=4 if partyln==2 & inrange(party,3,9)
replace PARTY5=3 if partyln==9 & inrange(party,3,9)
label define PARTY5 1 "1. Republican" 2 "2. Lean Republican"/*
	*/ 3 "3. Independent/Other/dk" 4 "4. Lean Democrat" 5 "5. Democrat"
label values PARTY5 PARTY5
recode PARTY5 (1/2=1) (3=2) (4/5=3), gen(PARTY3)
label define PARTY3 1 "1. Republican" 2 "2. Independent/Other/dk" 3 "3. Democrat"
label values PARTY3 PARTY3
label variable PARTY5 "five scale party using lean"
label variable PARTY3 "three scale party using lean"
label define regist 1 "1. yes" 2 "2. no" 3 "3. no need to register" 9 "9. dk"
label values regist regist
label variable regist "is respondent a registered voter"
label define ideology 1 "1. very conservative" 2 "2. conservative"/*
	*/ 3 "3. moderate" 4 "4. liberal" 5 "5. very liberal" 9 "9. dk"
label values ideology ideology
label variable ideology "respondent ideology"
label variable llweight "landline weight"
label variable coweight "cell weight"
label define response 1 "1. valid item-response" 0 "0. item non-response"
label values response response
drop sample
recode hispanic (1=1) (2=2) (8/9=9)
label define hispanic 1 "1. hispanic" 2 "2. not hispanic" 9 "9. dk"
label values hispanic hispanic
recode hispanic (1=1) (2/9=0), gen(HISPANIC)
label define race 1 "1. white" 2 "2. black" 3 "3. asian" 4 "4. other/mixed"/*
	*/ 9 "9. dk"
label values race race
recode race (1 3/9=0) (2=1), gen(BLACK)

rename question questionstr
gen field=.
replace field=1 if strmatch(questionstr,"*_d*")
replace field=2 if strmatch(questionstr,"*_f*")
label define field 1 "1. domestic" 2 "2. foreign"
label values field field
label variable field "question field: domestic vs. foreign"

gen question=questionstr
gen subquestion=""
replace subquestion="a" if strmatch(question,"*a_*")
replace subquestion="b" if strmatch(question,"*b_*")
replace subquestion="c" if strmatch(question,"*c_*")
replace subquestion="d" if strmatch(question,"*d_*")
replace subquestion="e" if strmatch(question,"*e_*")
replace subquestion="f" if strmatch(question,"*f_*")
replace subquestion="g" if strmatch(question,"*g_*")
replace subquestion="h" if strmatch(question,"*h_*")
replace subquestion="i" if strmatch(question,"*i_*")
replace subquestion="j" if strmatch(question,"*j_*")
replace subquestion="k" if strmatch(question,"*k_*")
replace subquestion="l" if strmatch(question,"*l_*")
replace subquestion="m" if strmatch(question,"*m_*")
replace subquestion="n" if strmatch(question,"*n_*")
replace subquestion="o" if strmatch(question,"*o_*")
replace subquestion="p" if strmatch(question,"*p_*")
replace subquestion="q" if strmatch(question,"*q_*")
replace subquestion="r" if strmatch(question,"*r_*")
replace subquestion="s" if strmatch(question,"*s_*")
replace subquestion="t" if strmatch(question,"*t_*")
replace subquestion="u" if strmatch(question,"*u_*")
replace subquestion="v" if strmatch(question,"*v_*")
replace subquestion="w" if strmatch(question,"*w_*")
replace subquestion="x" if strmatch(question,"*x_*")
replace subquestion="y" if strmatch(question,"*y_*")
replace subquestion="z" if strmatch(question,"*z_*")
replace subquestion="aa" if strmatch(question,"*aa_*")
replace subquestion="bb" if strmatch(question,"*bb_*")
replace subquestion="cc" if strmatch(question,"*cc_*")
replace subquestion="dd" if strmatch(question,"*dd_*")
replace subquestion="ee" if strmatch(question,"*ee_*")
replace subquestion="ff" if strmatch(question,"*ff_*")
replace subquestion="gg" if strmatch(question,"*gg_*")
replace subquestion="hh" if strmatch(question,"*hh_*")

replace question=subinstr(question,"_d","",.)
replace question=subinstr(question,"_f","",.)
replace question=subinstr(question,"aa","",.)
replace question=subinstr(question,"bb","",.)
replace question=subinstr(question,"cc","",.)
replace question=subinstr(question,"dd","",.)
replace question=subinstr(question,"ee","",.)
replace question=subinstr(question,"ff","",.)
replace question=subinstr(question,"gg","",.)
replace question=subinstr(question,"hh","",.)
replace question=subinstr(question,"a","",.)
replace question=subinstr(question,"b","",.)
replace question=subinstr(question,"c","",.)
replace question=subinstr(question,"d","",.)
replace question=subinstr(question,"e","",.)
replace question=subinstr(question,"f","",.)
replace question=subinstr(question,"g","",.)
replace question=subinstr(question,"h","",.)
replace question=subinstr(question,"i","",.)
replace question=subinstr(question,"j","",.)
replace question=subinstr(question,"k","",.)
replace question=subinstr(question,"l","",.)
replace question=subinstr(question,"m","",.)
replace question=subinstr(question,"n","",.)
replace question=subinstr(question,"o","",.)
replace question=subinstr(question,"p","",.)
replace question=subinstr(question,"q","",.)
replace question=subinstr(question,"r","",.)
replace question=subinstr(question,"s","",.)
replace question=subinstr(question,"t","",.)
replace question=subinstr(question,"u","",.)
replace question=subinstr(question,"v","",.)
replace question=subinstr(question,"w","",.)
replace question=subinstr(question,"x","",.)
replace question=subinstr(question,"y","",.)
replace question=subinstr(question,"z","",.)

destring question, replace
label variable questionstr "full question id from survey - string variable"
label variable question "question number from survey"
label variable subquestion "subquestion number from survey"

replace survey=lower(survey)
label define news 1 "1. very closely" 2 "2. fairly closely" ///
	3 "3. not too closely" 4 "4. not at all" 9 "9. dk"
foreach var of varlist news_isis news_robinwilliams news_ferguson news_ebola news_ukraine news_israel news_ma370 news_usborder news_health news_elections news_bowebergdahl news_powerplants news_econ news_veterans news_wiretaps news_toyota news_budget news_sat news_baseball news_govshut news_syria news_apple news_fire news_mlk news_nfl news_immigration news_sxasmil news_turkey news_emailtaps news_deficit news_pope news_afghan news_benghazi news_weather news_obama news_womencombat news_scourthealth news_oilleak news_flood news_carbomb news_police news_greece news_dc news_haiti news_iraq news_saddam news_ford news_somalia news_democrats news_secdef news_minister news_sudan news_russianspy news_hurricane news_iran news_jonbenet news_911 news_steveirwin news_terror news_gas news_castro news_melgibson news_senlieberman news_britterror news_lobbyists news_soccer news_zarqawi news_marines news_france news_tomdelay news_couric news_moussaoui news_usports news_cheney news_birdflu news_abortion news_scourt news_congressbribe news_miners news_iraqgov news_pakistan news_germany news_bali news_deepthroat news_newsweek news_eu news_bushsocsec news_mjackson news_stemcells news_marijuana news_socsec news_nkorea news_gov news_tsunami news_medication news_nba news_scottpeter news_intel news_arafat news_repconv news_olympics news_chechen news_cads news_clinton news_bush news_demnom news_fahrenheit news_madcow news_libya news_mars{
label values `var' news
}
order news_911 news_abortion news_afghan news_apple news_arafat news_bali news_baseball news_benghazi news_birdflu news_bowebergdahl news_britterror news_budget news_bush news_bushsocsec news_cads news_carbomb news_castro news_chechen news_cheney news_clinton news_congressbribe news_couric news_dc news_deepthroat news_deficit news_demnom news_democrats news_ebola news_econ news_elections news_emailtaps news_eu news_fahrenheit news_ferguson news_fire news_flood news_ford news_france news_gas news_germany news_gov news_govshut news_greece news_haiti news_health news_hurricane news_immigration news_intel news_iran news_iraq news_iraqgov news_isis news_israel news_jonbenet news_libya news_lobbyists news_ma370 news_madcow news_marijuana news_marines news_mars news_medication news_melgibson news_miners news_minister news_mjackson news_mlk news_moussaoui news_nba news_newsweek news_nfl news_nkorea news_obama news_oilleak news_olympics news_pakistan news_police news_pope news_powerplants news_repconv news_robinwilliams news_russianspy news_saddam news_sat news_scottpeter news_scourt news_scourthealth news_secdef news_senlieberman news_soccer news_socsec news_somalia news_stemcells news_steveirwin news_sudan news_sxasmil news_syria news_terror news_tomdelay news_toyota news_tsunami news_turkey news_ukraine news_usborder news_usports news_veterans news_weather news_wiretaps news_womencombat news_zarqawi, last

saveold SNR.dta, replace
}
* test variables
clear
use SNR.dta, clear
foreach var of varlist pollmethod sex age education party partyln regist ideology response survey vote2012 vote2008 vote2004 vote2000 VOTE PARTY5 PARTY3 field question subquestion race hispanic{
tab `var', m
}
*
* Add Polltype
{
clear
use SNR.dta, clear
gen polltype=.
replace polltype=1 if strmatch(survey,"*apw*") | strmatch(survey,"*com*")/*
	*/ | strmatch(survey,"*die*") | strmatch(survey,"*ear*")/*
	*/ | strmatch(survey,"*eco*") | strmatch(survey,"*ele*")/*
	*/ | strmatch(survey,"*fp*") | strmatch(survey,"*gen*")/*
	*/ | strmatch(survey,"*gov*") | strmatch(survey,"*gun*")/*
	*/ | strmatch(survey,"*hk*") | strmatch(survey,"*late*")/*
	*/ | strmatch(survey,"*mid*") | strmatch(survey,"*nii*")/*
	*/ | strmatch(survey,"*pi*") | strmatch(survey,"*pol*")/*
	*/ | strmatch(survey,"*post*") | strmatch(survey,"*prim*")/*
	*/ | strmatch(survey,"*turnout*") | strmatch(survey,"*typo*")/*
	*/ | strmatch(survey,"*value*") | strmatch(survey,"*vote*")/*
	*/ | survey=="uspew2009-09" | survey=="uspew2009-11"/*
	*/ | survey=="uspew2010-01"

replace polltype=2 if strmatch(survey,"*ia*") | strmatch(survey,"*sci*")/*
	*/ | survey=="uspew2009-06"
replace polltype=3 if strmatch(survey,"*media*") | strmatch(survey,"*wk*")
replace polltype=4 if strmatch(survey,"*rel*")
replace polltype=5 if strmatch(survey,"*sdt*")


label define polltype 1 "1. US Politics & Policy" 2 "2. Internet, Science & Tech"/*
	*/ 3 "3. Journalism & Media" 4 "4. Religion & Public Life"/*
	*/ 5 "5. Social & Demographic Trends"
label values polltype polltype
recode polltype (1=1) (2/5=0), gen(POLL_POLITICS)

saveold SNR.dta, replace
}
*
* Add unit response rate to each survey
{
clear
import excel using responserate.xlsx, firstrow
keep if imported==1
drop data imported
replace survey=lower(survey)

gen u=landlinerrate if missing(cellularrrate)
replace u=(landlinerrate*landline_n+cellularrrate*cellular_n)/(landline_n+cellular_n) if missing(u)

gen unitresponserate=u
recast int unitresponserate, force
gen h=u-unitresponserate
replace unitresponserate=unitresponserate+1 if h>=0.5 & !missing(h)
drop u h

keep survey unit
replace survey=lower(survey)
saveold responserate.dta, replace

clear
import excel using responserate.xlsx, firstrow
keep if imported==1
drop data imported note landline_n cellular_n
rename landlinerrate p_landlinerrate
rename cellularrrate p_cellularrrate
reshape long p, i(survey) j(temp) string
gen pollmethod=.
replace pollmethod=1 if strmatch(temp,"*land*")
replace pollmethod=2 if strmatch(temp,"*cell*")
rename p method_unitrr
drop temp
drop if missing(method_unitrr)
replace survey=lower(survey)
merge m:1 survey using responserate.dta

saveold responserate.dta, replace

clear
import excel using responserate.xlsx, firstrow
keep if imported==1
drop data imported note landlinerrate cellularrrate

rename landline_n p_landline_n
rename cellular_n p_cellular_n
reshape 
reshape long p, i(survey) j(temp) string
gen pollmethod=.
replace pollmethod=1 if strmatch(temp,"*land*")
replace pollmethod=2 if strmatch(temp,"*cell*")
rename p method_n
drop temp
drop if missing(method_n)
replace survey=lower(survey)
merge 1:1 survey pollmethod using responserate.dta, nogen
drop _merge
saveold responserate.dta, replace

clear
use SNR.dta, clear
rename response itemresponse
merge m:1 survey pollmethod using responserate.dta
drop _merge

label variable method_n "Original survey N per polling method"
label variable method_unitrr "Original unit response rate per polling method"
label variable unit "Unit response rate (weighted mean of landline & cellular rate)"
label variable polltype "Subject are of poll based on Pew classification"

saveold SNR.dta, replace
}
*
* Add indicator for first 20 questions in survey
{
clear
use SNR.dta, clear
recode question (1/20=1) (21/150=0), gen(first20)
replace first20=0 if survey=="uspew2004-03nii" & question==1
replace first20=0 if survey=="uspew2004-03nii" & question==3
replace first20=0 if survey=="uspew2004-ialsel" & question==1
replace first20=0 if survey=="uspew2004-ialsel" & question==7
replace first20=0 if survey=="uspew2004-ialsel" & question==9
replace first20=0 if survey=="uspew2004-ialsel" & question==11
replace first20=0 if survey=="uspew2004-ialsel" & question==17
replace first20=0 if survey=="uspew2004-ialsel" & question==19
replace first20=0 if survey=="uspew2005-02nii" & question==1
replace first20=0 if survey=="uspew2005-02nii" & question==2
replace first20=0 if survey=="uspew2005-02nii" & question==3
replace first20=0 if survey=="uspew2006-04nii" & question==1
replace first20=0 if survey=="uspew2006-04nii" & question==2
replace first20=0 if survey=="uspew2009-01pol" & question==3
replace first20=0 if survey=="uspew2009-02pol" & question==1
saveold SNR.dta, replace
}
*
* Add policy agendas categories
{
clear

import excel using questions.xlsx, firstrow sheet(all)
keep survey questionstr type
saveold questions_pap.dta, replace

clear
import excel using questions.xlsx, firstrow sheet(pap_types)
keep type pap
merge 1:m type using questions_pap.dta
drop _merge
saveold questions_pap.dta, replace
}
* Item Response Models - start here
* add policy agendas questions and prepare dummy variables
{
clear
set more off
use SNR.dta, clear
merge m:1 survey questionstr using questions_pap.dta
drop _merge

recode pap (1 5 15=1) (0 2/4 6/14 16/20=0), gen(ECONOMY)
recode pap (2 12=1) (0/1 3/10 13/20=0), gen(CIVIL_RIGHTS)
recode pap (3 6 13 14=1) (0/2 4/5 7/12 15/20=0), gen(WELFARE)
recode pap (7 8=1) (0/6 9/20=0), gen(ENERGY)
recode pap (9=1) (0/8 10/20=0), gen(IMMIGRATION)
recode pap (16 18 19=1) (0/15 17 20=0), gen(FOREIGN_AFFAIRS)
recode pap (20=1) (0/19=0), gen(GOVERNMENT)
recode pap (0 4 10 17=1) (1/3 5/9 12/16 18/19=0), gen(OTHER)

recode party (1=1) (2=2) (3/9=3), gen(PARTY)
label define PARTY 1 "1. Republican" 2 "2. Democrat" 3 "3. Independent"
label values PARTY PARTY

recode age (18/29=1) (30/49=2) (50/64=3) (65/98 100/200=4) (99=.), gen(agegroup)
label define agegroup 1 "18-29" 2 "30-49" 3 "50-65" 4 "65+"
label values agegroup agegroup

recode education (1/2=1) (3/5=2) (6/7=3) (9=.), gen(EDU)
label define EDU 1 "1. No High school" 2 "2. High school grad" 3 "3. Higher education"
label values EDU EDU

gen year=.
replace year=2004 if strmatch(survey,"*2004*")
replace year=2005 if strmatch(survey,"*2005*")
replace year=2006 if strmatch(survey,"*2006*")
replace year=2007 if strmatch(survey,"*2007*")
replace year=2008 if strmatch(survey,"*2008*")
replace year=2009 if strmatch(survey,"*2009*")
replace year=2010 if strmatch(survey,"*2010*")
replace year=2011 if strmatch(survey,"*2011*")
replace year=2012 if strmatch(survey,"*2012*")
replace year=2013 if strmatch(survey,"*2013*")
replace year=2014 if strmatch(survey,"*2014*")
replace year=2015 if strmatch(survey,"*2015*")

recode year (2004/2007=1) (2008/2015=2), gen(administration)
label define administration 1 "1. Bush" 2 "2. Obama" 
label values administration administration

egen id=concat(survey questionstr)

recode VOTE (1=1) (2/3=0), gen(VOTED)
recode regist (1=1) (2=0 9) (3=.), gen(REGISTERED)
recode PARTY (1=1) (2/3=0), gen(REPUBLICAN)
recode PARTY (1/2=0) (3=1), gen(INDEPENDENT) 	
recode field (1=0) (2=1), gen(FOREIGN)	
recode agegroup (1=1) (2/4=0), gen(AGE_18_29)
recode agegroup (2=1) (1 3/4=0), gen(AGE_30_49)
recode agegroup (1/3=0) (4=1), gen(AGE_65PLUS)
recode EDU (1=1) (2/3=0), gen(NOHS)
recode EDU (3=1) (1/2=0), gen(HIGHEREDU)
recode sex (1=0) (2=1), gen(FEMALE)

recode admin (1=0) (2=1), gen(OBAMA_ADMIN)
recode pollmethod (1=0) (2=1), gen(CELL)
* saveold SNR4R.dta, replace nolabel
recode PARTY3 (1=1) (2/3=0), gen(REP3)
recode PARTY3 (2=1) (1 3=0), gen(IND3)

gen elections=0
replace elections=1 if  survey=="USPEW2004-08NII" |/*
	*/  survey=="USPEW2004-09EAR" |  survey=="USPEW2004-09MID" |/*
	*/  survey=="uspew2004-10earpol" |  survey=="USPEW2004-10MIDPOL" |/*
	*/  survey=="USPEW2004-ELECWKND" |  survey=="USPEW2004-TYPO" |/*
	*/  survey=="USPEW2005-01NII" |  survey=="uspew2006-08NII" |/*
	*/  survey=="uspew2006-09nii" |  survey=="uspew2006-12nii" |/*
	*/  survey=="uspew2006-elec" |  survey=="uspew2006-postelec" |/*
	*/  survey=="uspew2006-turnout" |  survey=="uspew2007-01nii" |/*
	*/  survey=="uspew2008-09late" |  survey=="uspew2008-09mid" 
replace elections=1 if /*
	*/  survey=="uspew2008-10late" |  survey=="uspew2008-10mid" |/*
	*/  survey=="uspew2008-11elec" |  survey=="uspew2008-12pol" |/*
	*/  survey=="uspew2009-01pol" |  survey=="uspew2010-09pi" |/*
	*/  survey=="uspew2010-10pol" |  survey=="uspew2011-01pol" |/*
	*/  survey=="uspew2012-09pol" |  survey=="uspew2012-10ear" |/*
	*/  survey=="uspew2012-10late" |  survey=="uspew2012-12gun" |/*
	*/  survey=="uspew2012-12pol" |  survey=="uspew2012-sdt12" |/*
	*/  survey=="uspew2013-01pol" |  survey=="uspew2014-08pol" |/*
	*/  survey=="uspew2014-09rel" |  survey=="uspew2014-10pol" |/*
	*/  survey=="uspew2014-11post" |  survey=="uspew2014-12pol" |/*
	*/  survey=="uspew2014-wk0814" |  survey=="uspew2015-01pol" 
	
saveold SNR.dta, replace

* Create dataset of polarization in public opinion

clear

************************************
* prepare database
************************************
* import all questions
{
set more off
*** USPEW2004-01NII
{
infix 1 lines 1: weight 1321-1324  rid 1-6 sex 57 education 267/*
	*/ party 279 partyln 280 ideology 281 regist 277 age 265-266/*
	*/ q28_f 235 q31_f 240/*
	*/ race 269 hispanic 268/*
	*/ using Pew/USPEW2004-01NII.dat

gen survey="USPEW2004-01NII"	
gen pollmethod=1

local vars_1 q28_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q31_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

saveold SNR_t.dta, replace
}
*** USPEW2004-07FP
{
clear

use Pew/USPEW2004-07FP.dta, clear
rename educ education
rename ideo ideology
rename pvote00 vote
rename q25 q25_d
rename q26 q26_d
rename q32 q32_d
rename q34f1 q34_f
rename q36f2 q36_f
rename q37f1 q37_f
rename q45f1 q45_f
rename q46f2 q46_f
rename q47 q47_f
rename q48f1 q48_f
rename q52f2 q52_f
rename q54f1 q54_f
rename q60 q60_f
rename q61 q61_f
rename q62 q62_f
rename q64 q64_f
rename q72f1 q72_f
rename q73f2 q73_f
rename q77f2 q77_f
rename hisp hispanic

keep weight rid sex education party partyln ideology regist age/*
	*/ vote q25_d q26_d q32_d q34_f q36_f q37_f q45_f q46_f q47 q48_f/*
	*/ q52_f q54_f q60_f q62_f q64_f q72_f q73_f q77_f race hispanic

gen survey="USPEW2004-07FP"	
gen pollmethod=1

local vars_1 q25_d q26_d q32_d q36_f q37_f q45_f q46_f q48_f q52_f q54_f q60_f q62_f q64_f q72_f q73_f q77_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q34_f q47_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-08NII
{
clear
infix 1 lines 1: weight 318-321 rid 1-6 sex 19 age 206-207 education 208/*
	*/ regist 219 party 221 partyln 223 ideology 224 vote 225 /*
	*/ q36_d 172 q37_d 173 q41_d 177 q51_f 184 q53_f 186 q55_f 188 q61_f 198 /*
	*/ race 210 hispanic 209/*
	*/ using Pew/USPEW2004-08NII.dat

gen survey="USPEW2004-08NII"	
gen pollmethod=1


local vars_1 q36_d q37_d q41_d q51_f q53_f q55_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q61_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-09EAR
{
clear
infix 1 lines 1: weight 210-213 rid 1-6 sex 21 regist 38 age 135-136/*
	*/ education 137 party 147 partyln 149 ideology 150 vote 151 /*
	*/ q28_f 117 q30_f 119 q32_f 121 q36a_d 125 q36b_d 126 q38_d 128 q39_f 129/*
	*/ race 139 hispanic 138/*
	*/ using Pew/USPEW2004-09EAR.dat

gen survey="USPEW2004-09EAR"	
gen pollmethod=1

recode q39_f (5 9=.)
local vars_1 q28_f q30_f q32_f q36a_d q36b_d q38_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-09MID
{
clear
infix 1 lines 1: weight 105-108 rid 1-6 sex 20 regist 22 age 35-36/*
	*/ education 37 party 44 partyln 45 ideology 46/*
	*/ q10_f 29 q12_f 31/*
	*/ race 39 hispanic 38/*
	*/ using Pew/USPEW2004-09MID.dat

gen survey="USPEW2004-09MID"	
gen pollmethod=1

local vars_1 q10_f q12_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2004-10earpol
{
clear
infix 1 lines 1: weight 159-162 rid 1-8 sex 13 regist 15 age 108-109/*
	*/ education 110 party 120 partyln 121 ideology 122 vote 123/*
	*/ q23_f 104/*
	*/ race 112 hispanic 111/*
	*/ using Pew/uspew2004-10earpol.dat

gen survey="uspew2004-10earpol"	
gen pollmethod=1

local vars_1 q23_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-10MIDPOL
{
clear
infix 1 lines 1: weight 1131-1134 rid 1-4 sex 68 regist 92 age 807-808/*
	*/ education 809 party 1074 partyln 1076 ideology 1077 vote 1078/*
	*/ q40_f 778 q42_f 780 q43_f 781 q44_f 782/*
	*/ race 811 hispanic 810/*
	*/ using Pew/USPEW2004-10MIDPOL.dat

gen survey="USPEW2004-10MIDPOL"	
gen pollmethod=1

local vars_1 q40_f q42_f q43_f q44_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-ELECWKND
{
clear
infix 1 lines 1: weight 195-198 rid 1-4 sex 16 regist 23-24 age 85-86/*
	*/ education 87-88 party 105-106 partyln 109-110 ideology 111-112/*
	*/ vote 113-114/*
	*/ q14_f 77-78 /*
	*/ race 91-92 hispanic 89-90/*
	*/ using Pew/USPEW2004-ELECWKND.dat

gen survey="USPEW2004-ELECWKND"	
gen pollmethod=1

local vars_1 q14_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-04NII
{
clear 
infix 1 lines 1: weight 103-106 rid 1-6 sex 56 regist 87 age 80-81/*
	*/ education 82 party 89 partyln 90 ideology 91/*
	*/ q4_f 70 q6_f 72 q9_f 77/*  // q9_f example where neither is a valid answer
	*/ race 84 hispanic 83/*
	*/ using Pew/USPEW2004-04NII.dat

gen survey="USPEW2004-04NII"	
gen pollmethod=1

local vars_1 q4_f q6_f q9_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-04LATE
{
clear 
infix 1 lines 1: weight 73-76 rid 1-6 sex 48 age 60-61/*
	*/ education 62 party 67 partyln 68 ideology 69/*
	*/ q3_f 54 q5_f 56/* 
	*/ race 64 hispanic 63/*
	*/ using Pew/USPEW2004-04LATE.dat

* regist	
gen survey="USPEW2004-04LATE"	
gen pollmethod=1

local vars_1 q3_f q5_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-06VOTE
{
clear 
use Pew/USPEW2004-06VOTE.dta

rename educ education
rename ideo ideology
rename hisp hispanic
rename pvote00 vote
rename q51 q51_f
rename q53 q53_f
rename q56 q56_f //example of volunteered valid answer

keep weight rid sex age education regist vote party partyln ideology/*
	*/ q51_f q53_f q56_f race hispanic

* regist	
gen survey="USPEW2004-06VOTE"	
gen pollmethod=1

local vars_1 q51_f q53_f q56_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2004-03NII
{
clear 
infix 1 lines 1: weight 1296-1299 rid 1-6 sex 57 age 243-244/*
	*/ education 245 regist 252 party 254 partyln 255 ideology 256 vote 257/*
	*/ q1_f 170 q3_f 172 q29_f 194 q30_f 195 q31a_f 201 q31b_f 202/*
	*/ q31c_f 203 q31d_f 204 q31e_f 205 q37_d 227 q38_d 228/*
	*/ race 247 hispanic 246/*
	*/ using Pew/USPEW2004-03NII.dat

gen survey="USPEW2004-03NII"	
gen pollmethod=1

* q1_f = ir1 q3_f = ir3

local vars_1 q1_f q3_f q29_f q30_f q31a_f q31b_f q31c_f q31d_f q31e_f q37_d q38_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2004-ialsel
{
clear 
infix 1 lines 1: weight 20-23 rid 1-6 sex 25 age 191-192/*
	*/ education 195 party 202 ideology 203 regist 204/*
	*/ q23a_f 68 q23b_d 69 q23c_f 70 q23d_d 71 q23e_d 72/*
	*/ q1_f 104 q7a_f 113 q7b_f 115 q7c_f 117 q7d_f 119/*
	*/ q9b_f 123 q9d_f 127 q11_d 128 /*
	*/ q17a_d 137 q17b_d 139 q17c_d 141 q17d_d 143/*
	*/ q19a_d 145 q19b_d 147 q19c_d 149 q19d_d 151/*
	*/ q101_f 152 q107a_f 161 q107b_f 163 q107c_f 165 q107d_f 167/*
	*/ q109a_f 169 q109b_f 171 q109c_f 173 q109d_f 175/*
	*/ race 200 hispanic 199/*
	*/ using Pew/uspew2004-ialsel.dat

recode ideology (1=5) (2=4) (3=3) (4=2) (5=1) (9=9)	
recode race (1=1) (2=2) (3=3) (4/6=4) (9=9)
* q1_f = iraq1 | q7_f = iraq7 | q9_f = iraq9
* q11_d = gm1 | q17 = gm7 | q19 = gm9
* q101_f = ft1 q107 = ft7 | q109 = ft9
* vote partyln
gen survey="uspew2004-ialsel"	
gen pollmethod=1

local vars_1 q23a_f q23b_d q23c_f q23d_d q23e_d q1_f q11_d q101_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q7a_f q7b_f q7c_f q7d_f q9b_f q9d_f q17a_d q17b_d q17c_d q17d_d q19a_d q19b_d q19c_d q19d_d q107a_f q107b_f q107c_f q107d_f q109a_f q109b_f q109c_f q109d_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

append using SNR_t.dta
rename vote vote2000
saveold SNR_t.dta, replace
}
*** USPEW2004-TYPO
{
clear 
infix 1 lines 1: weight 161-164 rid 1-8 sex 32 age 128-129/*
	*/ education 131 party 143 partyln 145 ideology 148 regist 141/*
	*/ vote2004 149 q11b_d 56 q11d_d 58 q11g_d 61 q11i_f 62/*
	*/ q20q_d 85 q20r_d 86 q20u_d 89 q20v_d 90 q20bb_f 95/*
	*/ q20cc_f 96 q20dd_d 97 q20ee_d 98 q20ff_d 99/*
	*/ q32_d 102 q34_d 104 /*
	*/ q36a_d 106 q36b_d 107 q36c_d 108 q36d_d 109 q36e_d 110 /*
	*/ q37_f 111 q38_f 112 q41_f 113 q44_d 114 q45_f 115 q47_f 117 q49_d 119/*
	*/ race 133 hispanic 132/*
	*/ using Pew/USPEW2004-TYPO.dat

gen survey="USPEW2004-TYPO"	
gen pollmethod=1

local vars_1 q32_d q34_d q36a_d q36b_d q36c_d q36d_d q36e_d q37_f q38_f q41_f q44_d q45_f q47_f q49_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q11b_d q11d_d q11g_d q11i_f q20q_d q20r_d q20u_d q20v_d q20bb_f q20cc_f q20dd_d q20ee_d q20ff_d
foreach var of varlist `vars_2' {
recode `var' (5/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1/4=1) (5=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2005-01NII
{
clear 
infix 1 lines 1: weight 599-602 rid 1-8 sex 18 age 142-143/*
	*/ education 144 party 163-170 partyln 171-178 ideology 179-186 /*
	*/ regist 154 vote2004 187-194 q34_d 113/*
	*/ q40_f 132 q42_f 134 q53_f 140 q54_f 141 /* 
	*/ race 146 hispanic 145/*
	*/ using Pew/USPEW2005-01NII.dat

gen survey="USPEW2005-01NII"	
gen pollmethod=1

recode q54_f (5 9=.)
local vars_1 q40_f q42_f 
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q34_d q53_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2005-02NII
{
clear 
infix 1 lines 1: weight 1316-1319 rid 1-4 sex 20 age 172-173/*
	*/ education 174 party 185 partyln 186 ideology 187 /*
	*/ regist 183 vote2004 188/*
	*/ q12_d 58 q19a_d 101 q19b_d 102 q19c_d 103 q19d_d 104 q19e_d 105/*
	*/ q20_d 106 q26_d 126 q36_f 143 q38_f 145 q40_f 147 q48_d 155/*
	*/ q1_f 156 q2_f 157 q3_f 158/*
	*/ race 176 hispanic 175/*
	*/ using Pew/USPEW2005-02NII.dat

* q1_f q2_f q3_f = g1 g2 g3	
	
gen survey="USPEW2005-02NII"	
gen pollmethod=1

local vars_1 q12_d q19a_d q19b_d q19c_d q19d_d q19e_d q20_d q36_f q38_f q36_f q40_f q48_d q1_f q2_f q3_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q26_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2005-05NII
{
clear 
infix 1 lines 1: weight 194-197 rid 1-4 sex 25 age 117-118/*
	*/ education 119-120 party 133 partyln 134 ideology 135 /*
	*/ regist 131 vote2004 136 q22_d 77 q24_d 79/*
	*/ q29a_d 85 q29b_d 86 q29c_d 87 q29d_d 88 q29e_d 89 q29f_d 90/*
	*/ race 122 hispanic 121/*
	*/ using Pew/USPEW2005-05NII.dat
	
gen survey="USPEW2005-05NII"	
gen pollmethod=1

local vars_1 q22_d q24_d q29a_d q29b_d q29c_d q29d_d q29e_d q29f_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2005-06NII
{
clear 
infix 1 lines 1: weight 252-255 rid 1-4 sex 112 age 113-114/*
	*/ education 115 party 127 partyln 128 ideology 129 /*
	*/ regist 125 vote2004 130 q20_f 91 q22_f 93 q37_d 111/*
	*/ race 117 hispanic 116/*
	*/ using Pew/USPEW2005-06NII.dat

gen survey="USPEW2005-06NII"	
gen pollmethod=1

local vars_1 q20_f q22_f q37_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2005-apw
{
clear 
infix 1 lines 1: weight 609-612 rid 1-4 sex 22 age 240-241/*
	*/ education 242 party 254 partyln 255 ideology 256 /*
	*/ regist 252 vote2004 257 q9_f 164 q11_f 166 q13_f 168/*
	*/ q14a_f 169 q14b_f 170 q14c_f 171 q14d_f 172 q14e_f 173 q14f_f 174 q14g_f 175/*
	*/ q19_f 192 q21_f 194 q24_f 197 q25_f 198 q26_f 199 q27_f 200/*
	*/ q34_f 207 q35_f 208 q36_f 209 q41_f 221 q43_f 236 q45_f 238/*
	*/ race 244 hispanic 243/*
	*/ using Pew/uspew2005-apw.dat

gen survey="uspew2005-apw"	
gen pollmethod=1

local vars_1 q9_f q11_f q13_f q14a_f q14b_f q14c_f q14d_f q14e_f q14f_f q14g_f q19_f q21_f q25_f q26_f q27_f q34_f q35_f q36_f q41_f q43_f q45_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q24_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2005-die
{
clear 
infix 1 lines 1: weight 404-407 rid 1-4 sex 21 age 81-82/*
	*/ education 83 party 98 partyln 99 ideology 100 /*
	*/ regist 96 vote2004 101 q40_d 75 q42_d 77 q43_d 78/*
	*/ race 85 hispanic 84/*
	*/ using Pew/uspew2005-die.dat

gen survey="uspew2005-die"	
gen pollmethod=1

local vars_1 q40_d q42_d q43_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** USPEW2005-RELIG
{
clear 
infix 1 lines 1: weight 399-402 rid 1-4 sex 40 age 146-147/*
	*/ education 148 party 156 partyln 157 ideology 158 /*
	*/ regist 154 vote2004 159 /*
	*/ q3a_d 44 q3b_d 45 q3c_d 46 q3d_d 47 q3e_d 48 /*
	*/ q3f_d 49 q3g_d 50 q3h_d 51 q3i_d 52 q3j_d 53 /*
	*/ q6_f 54 q8_f 56 q21_d 87 q22_f 88 q23_f 89/*
	*/ race 150 hispanic 149/*
	*/ using Pew/USPEW2005-RELIG.dat

gen survey="USPEW2005-RELIG"	
gen pollmethod=1

local vars_1 q3a_d q3b_d q3c_d q3d_d q3e_d q3f_d q3g_d q3h_d q3i_d q3j_d q8_f q22_f q23_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q6_f q21_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-01nii
{
clear 
infix 1 lines 1: weight 677-680 rid 1-4 sex 23 age 131-132/*
	*/ education 133 party 145 partyln 146 ideology 147 /*
	*/ regist 143 vote2004 148 /*
	*/ q45_d 99 q46_d 100 q48_d 102 q53_f 103 q55_f 105 q57_f 107/*
	*/ q58_f 108 q70a_d 122 q70b_d 123 q70c_d 124 q70d_d 125/*
	*/ q71_d 126 q73_f 128/*
	*/ race 135 hispanic 134/*
	*/ using Pew/uspew2006-01nii.dat

gen survey="uspew2006-01nii"	
gen pollmethod=1

local vars_1 q45_d q46_d q48_d q53_f q55_f q57_f q58_f q70a_d q70b_d q70c_d q70d_d q71_d q73_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-03nii
{
clear 
infix 1 lines 1: weight 1854-1857 rid 1-4 sex 20 age 153-154/*
	*/ education 155 party 167 partyln 168 ideology 169 /*
	*/ regist 165 vote2004 170 /*
	*/ q11_d 48 q14_d 51 q28_f 75 q29_d 76 q33_d 90 q34_d 92/*
	*/ q60_f 133 q63_f 136 q65_f 138 q69_f 140/*
	*/ race 157 hispanic 156/*
	*/ using Pew/uspew2006-03nii.dat

gen survey="uspew2006-03nii"	
gen pollmethod=1

local vars_1 q11_d q14_d q28_f q33_d q34_d q60_f q63_f q65_f q69_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q29_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-04nii
{
clear 
infix 1 lines 1: weight 868-871 rid 1-4 sex 20 age 115-116/*
	*/ education 117 party 129 partyln 130 ideology 133 /*
	*/ regist 127 vote2004 134 /*
	*/ q1_d 55 q2_d 56 q45_f 97 q47_f 99 q53_f 105/*
	*/ race 119 hispanic 118/*
	*/ using Pew/uspew2006-04nii.dat

* q1 q2 = c1 c2	
	
gen survey="uspew2006-04nii"	
gen pollmethod=1

local vars_1 q1_d q2_d q45_f q47_f q53_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-06nii
{
clear 
infix 1 lines 1: weight 281-284 rid 1-4 sex 28 age 148-149/*
	*/ education 150 party 262 partyln 263 ideology 268 /*
	*/ regist 260 vote2004 269 /*
	*/ q37_d 80 q39_d 82 q50_f 88 q52_f 90 q53_f 91 q54_f 92/*
	*/ race 152 hispanic 151/*
	*/ using Pew/uspew2006-06nii.dat

gen survey="uspew2006-06nii"	
gen pollmethod=1

local vars_1 q37_d q39_d q50_f q52_f q53_f q54_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-08NII
{
clear 
infix 1 lines 1: weight 196-199 rid 1-5 sex 22 age 160-161/*
	*/ education 162 party 174 partyln 175 ideology 176 /*
	*/ regist 172 vote2004 177 /*
	*/ q19_f 97 q21_f 99 q27_f 111 q28_f 112 q64_f 150/*
	*/ q65_f 151 q66_f 152 q68_f 154/*
	*/ race 164 hispanic 163/*
	*/ using Pew/uspew2006-08NII.dat

gen survey="uspew2006-08NII"	
gen pollmethod=1

local vars_1 q19_f q21_f q27_f q64_f q65_f q66_f q68_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q28_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-09nii
{
clear 
infix 1 lines 1: weight 166-169 rid 1-8 sex 25 age 129-130/*
	*/ education 131 party 144 partyln 146 ideology 149 /*
	*/ regist 142 vote2004 150 /*
	*/ q31_d 104 q41_d 106 q42_d 107 q44_f 110 q45_f 111/*
	*/ q46_f 112 q55_f 117 q58_f 119 q59_f 120 q61_f 121/*
	*/ race 133 hispanic 132/*
	*/ using Pew/uspew2006-09nii.dat

gen survey="uspew2006-09nii"	
gen pollmethod=1

local vars_1 q31_d q41_d q42_d q44_f q45_f q46_f q55_f q58_f q59_f q61_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-12nii
{
clear 
infix 1 lines 1: weight 546-549 rid 1-4 sex 21 age 413-414/*
	*/ education 415 party 528 partyln 529 ideology 530 /*
	*/ regist 526 vote2004 531 /*
	*/ q12_f 367 q13_f 368 q19c_d 376 q20_f 377 q22_f 379 q26_f 383/*
	*/ q31a_f 388 q31b_f 389 q31c_f 390 q31d_f 390/*
	*/ q37_f 395 q42a_d 404 q42b_d 405 q42bb_d 406 q42c_d 407/*
	*/ q42cc_d 408 q42d_f 409 q44_f 411/*
	*/ race 417 hispanic 416/*
	*/ using Pew/uspew2006-12nii.dat

gen survey="uspew2006-12nii"	
gen pollmethod=1

local vars_1 q12_f q13_f q19c_d q20_f q22_f q26_f q31a_f q31b_f q31c_f q31d_f q37_f q42a_d q42b_d q42bb_d q42c_d q42cc_d q42d_f q44_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-elec
{
clear 
infix 1 lines 1: weight 116-119 rid 1-6 sex 81 age 83-84/*
	*/ education 85 party 96 partyln 98 ideology 101 /*
	*/ regist 29 vote2004 102  /*
	*/ q23_d 63 q24_d 64 q25_d 65 q28_f 72 q30_f 74/*
	*/ race 87 hispanic 86/*
	*/ using Pew/uspew2006-elec.dat

gen survey="uspew2006-elec"	
gen pollmethod=1

local vars_1 q23_d q24_d q25_d q28_f q30_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-postelec
{
clear 
infix 1 lines 1: weight 907-910 rid 1-4 sex 22 age 821-822/*
	*/ education 823 party 887 partyln 889 ideology 892 /*
	*/ regist 30 vote2004 893  /*
	*/ q42_f 802 q44_f 804 q49_f 809 q50_f 810 q51_f 811/*
	*/ race 825 hispanic 824/*
	*/ using Pew/uspew2006-postelec.dat

gen survey="uspew2006-postelec"	
gen pollmethod=1

local vars_1 q42_f q44_f q49_f q50_f q51_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2006-turnout
{
clear 
infix 1 lines 1: weight 843-846 rid 1-4 sex 396 age 397-398/*
	*/ education 399 party 460 partyln 462 ideology 465 /*
	*/ regist 31 vote2004 466  /*
	*/ q54_f 386 q56_f 388 q57_f 389 q58_f 390/*
	*/ race 401 hispanic 400/*
	*/ using Pew/uspew2006-turnout.dat

gen survey="uspew2006-turnout"	
gen pollmethod=1

local vars_1 q54_f q56_f q57_f q58_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-01nii
{
clear 
infix 1 lines 1: weight 789-793 rid 1-4 sex 22 age 640-641/*
	*/ education 642 party 754 partyln 755 ideology 756 /*
	*/ regist 752 /*
	*/ q30_d 610 q37_f 626 q39_f 628 q44_f 633/*
	*/ race 644 hispanic 643/*
	*/ using Pew/uspew2007-01nii.dat

* vote	
	
gen survey="uspew2007-01nii"	
gen pollmethod=1

local vars_1 q30_d q37_f q39_f q44_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-02pol
{
clear 
infix 1 lines 1: weight 1028-1031 rid 1-4 sex 955 age 956-957/*
	*/ education 958 party 1020 partyln 1021 ideology 1022 /*
	*/ regist 1018 /*
	*/ q33_d 835 q37_f 929 q39_f 931 q44_f 936 q45_f 937 q57_f 954/*
	*/ race 960 hispanic 959/*
	*/ using Pew/uspew2007-02pol.dat

* vote	
	
gen survey="uspew2007-02pol"	
gen pollmethod=1

local vars_1 q33_d q37_f q39_f q44_f q45_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q57_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-03pol
{
clear 
infix 1 lines 1: weight 1190-1193 rid 1-8 sex 98 age 99-100/*
	*/ education 101 party 216 partyln 218 ideology 219 /*
	*/ regist 214 /*
	*/ q45_f 82 q47_f 84 q51_f 88 q56_d 93/*
	*/ race 103 hispanic 102/*
	*/ using Pew/uspew2007-03pol.dat

* vote	
	
gen survey="uspew2007-03pol"	
gen pollmethod=1

local vars_1 q45_f q47_f q51_f q56_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-04pol
{
clear 
infix 1 lines 1: weight 179-182 rid 1-8 sex 24 age 155-156/*
	*/ education 157 party 36 partyln 38 ideology 171 /*
	*/ regist 169 /*
	*/ q20_d 77 q21_d 78 q36_d 123 q45_f 126 q47_f 128 q50_f 131 q51_f 132/*
	*/ q57a_f 138 q57b_f 139 q57c_f 140 q57d_f 141/*
	*/ race 159 hispanic 158/*
	*/ using Pew/uspew2007-04pol.dat

* vote	
	
gen survey="uspew2007-04pol"	
gen pollmethod=1

local vars_1 q20_d q21_d q36_d q45_f q47_f q50_f q51_f q57a_f q57b_f q57c_f q57d_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

duplicates drop rid, force // a few duplicated responses for some reason
reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-06pol
{
clear 
infix 1 lines 1: weight 321-324 rid 1-8 sex 25 age 92-93/*
	*/ education 94 party 307 partyln 309 ideology 310 /*
	*/ regist 305 /*
	*/ q40_d 68 q41_d 69 q42_d 70 q55_f 74/*
	*/ q56_f 75 q57_f 76 q59_f 78 q65_f 90/*
	*/ race 96 hispanic 95/*
	*/ using Pew/uspew2007-06pol.dat

* vote	
	
gen survey="uspew2007-06pol"	
gen pollmethod=1

local vars_1 q40_d q41_d q42_d q55_f q56_f q57_f q59_f q65_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-09pol
{
clear 
infix 1 lines 1: weight 494-497 rid 1-8 sex 237 age 238-239/*
	*/ education 240 party 148 partyln 149 ideology 254 /*
	*/ regist 252 /*
	*/ q47_f 210 q49_f 212 /*
	*/ race 242 hispanic 241/*
	*/ using Pew/uspew2007-09pol.dat

* vote	
	
gen survey="uspew2007-09pol"	
gen pollmethod=1

local vars_1 q47_f q49_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-10pol
{
clear 
infix 1 lines 1: pollmethod 12 weight 1195-1198 rid 1-5 sex 638 age 639-640/*
	*/ education 641 party 655 partyln 656 ideology 659 /*
	*/ regist 653 llweight 1187-1190 coweight 1191-1194/*
	*/ q56_d 630 q57_f 631 q59_f 633 q63_f 637/*
	*/ race 643 hispanic 642/*
	*/ using Pew/uspew2007-10pol.dat

* vote	
	
gen survey="uspew2007-10pol"	
* gen pollmethod=1

local vars_1 q56_d q57_f q59_f q63_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-11prim
{
clear
infix 1 lines 1: weight 927-931 rid 1-4 sex 25 age 850-851/*
	*/ education 852 party 190 partyln 191 ideology 914 /*
	*/ regist 188 /*
	*/ q32_f 793 q35_d 813 q36_d 814 q37_d 816 q38_d 817 q39_d 818/*
	*/ q40_d 819 q41_d 820 q42_f 821 q44_f 823 q45_d 824 /*
	*/ race 854 hispanic 853/*
	*/ using Pew/uspew2007-11prim.dat

* vote	
	
gen survey="uspew2007-11prim"	
gen pollmethod=1

local vars_1 q32_f q35_d q36_d q37_d q38_d q39_d q40_d q41_d q42_f q44_f q45_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}	
*** uspew2007-12pol	
{	
clear
infix 1 lines 1: pollmethod 30 weight 675-679 rid 1-7 sex 538 age 539-540/*
	*/ education 541 party 223 partyln 224 ideology 633 /*
	*/ regist 221 llweight 665-669 coweight 670-674/*
	*/ q48_d 529 q49_d 530 q51_f 531 q53_f 533/*
	*/ race 543 hispanic 542/*
	*/ using Pew/uspew2007-12pol.dat

* vote	
	
gen survey="uspew2007-12pol"

local vars_1 q48_d q49_d q51_f q53_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2007-sdt07
{
clear
infix 1 lines 1: weight 146-150 rid 1-4 sex 21 age 119-120/*
	*/ education 121 party 131 partyln 133 ideology 134 /*
	*/ regist 129 sample 18/*
	*/ q9a_d 39 q9b_d 40 q9c_d 41 q22_d 54 q29_d 62 q31_d 64 /*
	*/ q34_d 65 q36_d 66 q59_d 103 q60_d 104/*
	*/ race 47 hispanic 46/*
	*/ using Pew/uspew2007-sdt07.dat

drop if sample !=1	
* vote	
gen pollmethod=1	
gen survey="uspew2007-sdt07"

local vars_1 q9a_d q9b_d q9c_d q29_d q34_d q59_d q60_d	 
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q22_d q31_d q36_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}	
*** uspew2008-01pol	
{	
clear
infix 1 lines 1: weight 375-378 rid 1-5 sex 19 age 270-271/*
	*/ education 272 party 195 partyln 196 ideology 285 /*
	*/ regist 193 /*
	*/ q35a_d 266 q35b_d 267 q35c_d 268 q35d_d 269/*
	*/ race 274 hispanic 273/*
	*/ using Pew/uspew2008-01pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-01pol"

local vars_2 q35a_d q35b_d q35c_d q35d_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace	
}
*** uspew2008-02pol
{
clear
infix 1 lines 1: weight 143-145 rid 1-4 sex 121 age 122-123/*
	*/ education 124 party 27 partyln 28 ideology 134 /*
	*/ regist 25 /*
	*/ q55_f 76 q57_f 78 q63_d 91 q65_d 93/*
	*/ q66a_d 94 q66b_d 95 q66c_d 96 q66d_d 97 q66e_d 98 q66f_d 99 q66g_d 100 /*
	*/ q72_d 105 q73_f 106 q74_f 107 q79_f 108 q81_f 110 q86_d 112/*
	*/ race 126 hispanic 125/*
	*/ using Pew/uspew2008-02pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-02pol"

local vars_1 q55_f q57_f q63_d q65_d q66a_d q66b_d q66c_d q66d_d q66e_d q66f_d q66g_d q72_d q73_f q74_f q79_f q81_f q86_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace	
}	
*** uspew2008-03pol	
{	
clear
infix 1 lines 1: weight 151-154 rid 1-4 sex 118 age 119-120/*
	*/ education 121 party 23 partyln 24 ideology 133 /*
	*/ regist 21 /*
	*/ q82a_d 107 q82b_d 108 q82c_d 109 q82f_d 112 /*
	*/ race 123 hispanic 122/*
	*/ using Pew/uspew2008-03pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-03pol"

local vars_1 q82a_d q82b_d q82c_d q82f_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace
}	
*** uspew2008-05pol	
{	
clear
infix 1 lines 1: weight 215-219 rid 1-4 sex 16 age 140-141/*
	*/ education 142 party 55 partyln 56 ideology 153 /*
	*/ regist 22 q30a_f 100 q30b_f 101 q30c_f 102 q30d_f 103 q30e_f 104 q30f_f 105/*
	*/ q34_d 108 q35_d 109/*
	*/ race 144 hispanic 143/*
	*/ using Pew/uspew2008-05pol.dat

* vote	
gen pollmethod=1	
gen survey="uspew2008-05pol"

local vars_1 q30a_f q30b_f q30c_f q30d_f q30e_ q30f_f q34_d q35_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)
append using SNR_t.dta
saveold SNR_t.dta, replace	
}	
*** uspew2008-09late
{
clear
infix 1 lines 1: pollmethod 26 weight 129-133 rid 1-5 sex 27 age 86-87/*
	*/ education 88 party 103 partyln 104 ideology 105 /*
	*/ regist 30 vote2004 106 llweight 134-139 coweight 140-145/*
	*/ q44_d 79 q45_d 80 q47a_d 82 q47d_d 85/*
	*/ race 123 hispanic 89/*
	*/ using Pew/uspew2008-09late.dat

gen survey="uspew2008-09late"

local vars_1 q44_d q45_d q47a_d q47d_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2008-09mid	
{	
clear
infix 1 lines 1: pollmethod 21-22 weight 239-243 rid 1-5 sex 34 age 188-189/*
	*/ education 190 party 204 partyln 205 ideology 208 /*
	*/ regist 40 vote2004 209 llweight 244-248 coweight 249-253/*
	*/ q47_f 166 q49_f 168 q51_f 170 q53_f 171 q55_d 172 q56_d 173/*
	*/ q57a_d 174 q57b_d 175 q57c_d 176 q57d_d 177 q57e_d 178 q57f_d 179/*
	*/ q64_f 186 q65_f 187/*
	*/ race 232 hispanic 191/*
	*/ using Pew/uspew2008-09mid.dat

tab pollmethod	
gen survey="uspew2008-09mid"

local vars_1 q47_f q49_f q51_f q53_f q55_d q56_d q57a_d q57b_d q57c_d q57d_d q57e_d q57f_d q64_f q65_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}	
*** uspew2008-10late
{	
clear
infix 1 lines 1: pollmethod 39 weight 199-203 rid 1-5 sex 42 age 96-97/*
	*/ education 98 party 170 partyln 171 ideology 172 /*
	*/ regist 47 vote2004 173 llweight 204-208 coweight 209-213/*
	*/ q14_d 80 q16a_d 83 q16b_d 84 q16c_d 85 q16d_d 86 q17_d 87/*
	*/ q19_f 89 q22a_d 90 q22b_d 91 q22d_d 93/*
	*/ race 105 hispanic 99/*
	*/ using Pew/uspew2008-10late.dat

tab pollmethod	
gen survey="uspew2008-10late"

local vars_1 q16a_d q16b_d q16c_d q16d_d q17_d q19_f q22a_d q22b_d q22d_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q14_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2008-10mid	
{	
clear
infix 1 lines 1: pollmethod 14 weight 322-326 rid 1-5 sex 39 age 214-215/*
	*/ education 216 party 293 partyln 294 ideology 295 /*
	*/ regist 43 vote2004 296 llweight 327-331 coweight 332-336/*
	*/ q34_d 195 q36_f 197 q38_f 199/*
	*/ race 223 hispanic 217/*
	*/ using Pew/uspew2008-10mid.dat

tab pollmethod	
gen survey="uspew2008-10mid"

local vars_1 q34_d q36_f q38_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2008-11elec	
{
clear
infix 1 lines 1: pollmethod 33 weight 181-185 rid 1-5 sex 34 age 91-92/*
	*/ education 94 party 112 partyln 113 ideology 114 /*
	*/ regist 39 vote2004 117 llweight 156-159 coweight 160-163/*
	*/ q17_f 90/*
	*/ race 102 hispanic 96/*
	*/ using Pew/uspew2008-11elec.dat

tab pollmethod	
gen survey="uspew2008-11elec"

local vars_1 q17_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2008-12pol
{
clear
infix 1 lines 1: pollmethod 37 weight 200-206 rid 1-6 sex 45 age 153-154/*
	*/ education 156 party 178 partyln 179 ideology 180 /*
	*/ regist 176 vote2004 182 llweight 207-213 coweight 214-220/*
	*/ q15b_d 74 q15c_d 75 q15e_d 76 q50_d 124/*
	*/ q53a_d 126 q53b_d 127 q53c_d 128/*
	*/ race 164 hispanic 158/*
	*/ using Pew/uspew2008-12pol.dat

tab pollmethod	
gen survey="uspew2008-12pol"

local vars_1 q50_d q53a_d q53b_d q53c_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q15b_d q15c_d q15e_d 
foreach var of varlist `vars_2' {
recode `var' (5/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2008-sdt08
{
clear
infix 1 lines 1: pollmethod 15 weight 205-209 rid 1-8 sex 27 age 147-148/*
	*/ education 149 party 167 partyln 168 ideology 169 /*
	*/ regist 165 /*
	*/ q10_d 47/*
	*/ race 151 hispanic 150/*
	*/ using Pew/uspew2008-sdt08.dat

* vote2004	
tab pollmethod	
gen survey="uspew2008-sdt08"

local vars_1 q10_d 
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2004 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2009-01pol
{
clear
infix 1 lines 1: pollmethod 27 weight 184-188 rid 1-6 sex 144 age 145-146/*
	*/ education 147 party 165 partyln 166 ideology 167 /*
	*/ regist 163 vote2008 168 llweight 189-193 coweight 194-198 /*
	*/ q3_f 111 q33a_f 104 q33b_f 105 q33c_f 106 q33d_f 107/*
	*/ q33e_f 108 q33f_f 109 q33g_f 110/*
	*/ q34_f 112 q36_f 114 q49_f 133/*
	*/ q51_f 135 q58_f 140 q59_f 141 q60_f 142 q62_f 143/*
	*/ race 154 hispanic 148/*
	*/ using Pew/uspew2009-01pol.dat

* q3_f = qa3	
tab pollmethod	
gen survey="uspew2009-01pol"

local vars_1 q33a_f q33b_f q33c_f q33d_f q33e_f q33f_f q33g_f q34_f q36_f q49_f q51_f q58_f q59_f q60_f q62_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q3_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2009-02pol
{
clear
infix 1 lines 1: pollmethod 27 weight 191-195 rid 1-6 sex 141 age 142-143/*
	*/ education 145 party 170 partyln 171 ideology 172 /*
	*/ regist 168 vote2008 174 llweight 196-200 coweight 201-205 /*
	*/ q1_d 101 q46_d 138 q47_d 139 q48_f 140/*
	*/ race 155 hispanic 149/*
	*/ using Pew/uspew2009-02pol.dat

* q1_d = qa
tab pollmethod	
gen survey="uspew2009-02pol"

local vars_1 q1_d q47_d q48_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q1_d q46_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2009-03pol
{
clear
infix 1 lines 1: pollmethod 27 weight 133-137 rid 1-6 sex 94 age 95-96/*
	*/ education 98 party 119 partyln 120 ideology 121 /*
	*/ regist 117 llweight 138-142 coweight 143-147 /*
	*/ q13_d 54 q14_d 55 q15_d 56 q36_d 71/*
	*/ hispanic 102 race 108/*
	*/ using Pew/uspew2009-03pol.dat

* vote2008	
tab pollmethod	
gen survey="uspew2009-03pol"

local vars_1 q14_d q15_d q36_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q13_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2009-05sci
{
clear
infix 1 lines 1: pollmethod 13 weight 172-176 rid 1-6 sex 112 age 113-114/*
	*/ education 115 party 145 partyln 146 ideology 147 /*
	*/ regist 143 llweight 177-181 coweight 182-186 /*
	*/ q50a_d 98 q50b_d 99 q51_d 101/*
	*/ hispanic 120 race 126/*
	*/ using Pew/uspew2009-05sci.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-05sci"

local vars_1 q50a_d q50b_d q51_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-06
{
clear
infix 1 lines 1: pollmethod 13 weight 74-78 rid 1-6 sex 56 age 57-58/*
	*/ education 64 party 59 /*
	*/ q1a_d 27 q1b_d 28 q1c_d 29 q1d_f 30 q1e_d 31/*
	*/ q1f_d 32 q1g_f 33 q1h_f 34 q1i_f 35 q1j_d 36/*
	*/ q1k_d 37 q1l_d 38 q1m_d 39 q1n_d 40 q12_d 55/*
	*/ hispanic 65 race 66/*
	*/ using Pew/uspew2009-06.dat

recode hispanic (1=1) (2=2) (8/9=9)	
recode race (1=1) (2=2) (3=3) (4/6=4) (8/9=9)
* partyln
* ideology	
* regist
* vote2008	
tab pollmethod 
gen survey="uspew2009-06"

local vars_1 q1a_d q1b_d q1c_d q1d_f q1e_d q1f_d q1g_f q1h_f q1i_f q1j_d q1k_d q1l_d q1m_d q1n_d q12_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-06pol
{
clear
infix 1 lines 1: pollmethod 28 weight 224-228 rid 1-6 sex 174 age 175-176/*
	*/ education 177 party 202 partyln 203 ideology 204 /*
	*/ regist 200 llweight 229-233 coweight 234-238/*
	*/ q32a_d 128 q32b_d 129 q32c_d 130/*
	*/ q47a_f 151 q47b_f 152 q47c_f 153 q47d_f 154 q47e_f 155 q47f_f 156 q47g_f 157/*
	*/ q56_d 170/*
	*/ hispanic 181 race 187/*
	*/ using Pew/uspew2009-06pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-06pol"

local vars_1 q32a_d q32b_d q32c_d q47a_f q47b_f q47c_f q47d_f q47e_f q47f_f q47g_f q56_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-09
{
clear
infix 1 lines 1: pollmethod 7 weight 134-138 rid 1-6 sex 79 age 80-81/*
	*/ education 86 party 107 partyln 108 ideology 109 /*
	*/ regist 105 llweight 124-128 coweight 129-133/*
	*/ q2_d 66 q49_f 68/*
	*/ hispanic 91 race 92/*
	*/ using Pew/uspew2009-09.dat

recode hispanic (1=1) (2=2) (8/9=9)
recode race (1=1) (2=2) (3=3) (4=4) (8/9=9)	
* q2_d = qh2	
replace age=99 if age==98	
replace regist=9 if regist==8
replace party=9 if party==8
replace partyln=9 if party==7 | party==8
replace ideology=9 if ideology==8
* vote2008	
tab pollmethod 
gen survey="uspew2009-09"

local vars_1 q2_d q49_f
foreach var of varlist `vars_1' {
recode `var' (8/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 150-154 rid 1-6 sex 41 age 105-106/*
	*/ education 107 party 131 partyln 132 ideology 133 /*
	*/ regist 129/*
	*/ q17_d 59 q19_d 61 q32a_d 69 q32b_d 70 q32c_d 71 /* // q32 examples for valid volunteered response
	*/ q46_d 85 q49a_d 89 q49b_d 90 q49c_d 91 q49d_d 92/*
	*/ q49e_d 93 q49f_d 94 q56_d 98 q60_f 100 q62_f 102 q64_f 104/*
	*/ hispanic 108 race 116/*
	*/ using Pew/uspew2009-10pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2009-10pol"

local vars_1 q17_d q32a_d q32b_d q32c_d q46_d q49a_d q49b_d q49c_d q49d_d q49e_d q49f_d q56_d q60_f q62_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q19_d q64_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-10sdt
{
clear
infix 1 lines 1: pollmethod 7 weight 221-225 rid 1-6 sex 46 age 163-164/*
	*/ education 165 party 175 partyln 176 ideology 178 /*
	*/ regist 173/*
	*/ q8_d 69 q10_d 71 q38_d 95/*
	*/ hispanic 75 race 80/*
	*/ using Pew/uspew2009-10sdt.dat

recode race (1=1) (2=2) (3=3) (5=4) (9=9)	
drop if pollmethod==2 | pollmethod==4
replace pollmethod=2 if pollmethod==3	
* vote2008	
tab pollmethod 
gen survey="uspew2009-10sdt"

local vars_2 q8_d q10_d q38_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-11
{
clear
infix 1 lines 1: pollmethod 11 weight 79-83 rid 1-6 sex 50 age 51-52/*
	*/ education 63 party 55 partyln 56 /*
	*/ q2_d 22 q6_d 37/*
	*/ q7a_f 38 q7b_f 39 q7c_f 40 q7d_f 41 q7e_f 42 q12_d 47/*
	*/ hispanic 65 race 66/*
	*/ using Pew/uspew2009-11.dat

recode race (1=1) (2=2) (3=3) (4/6=4) (8/9=9)
recode hispanic (1=1) (2=2) (8/9=9)	
	
* vote2008
* ideology	
* regist
tab pollmethod 
gen survey="uspew2009-11"

local vars_1 q2_d q7a_f q7b_f q7c_f q7d_f q7e_f q12_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q6_d 
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 223-227 rid 1-6 sex 160 age 161-162/*
	*/ education 165 party 194 partyln 195 ideology 197/*
	*/ regist 192 llweight 213-217 coweight 218-222/*
	*/ q25_d 92/*
	*/ hispanic 170 race 176/*
	*/ using Pew/uspew2009-12pol.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-12pol"

local vars_1 q25_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-apw
{
clear
infix 1 lines 1: pollmethod 45 weight 386-390 rid 1-6 sex 48 age 261-262/*
	*/ education 263-264 party 305-306 partyln 307-308 ideology 309-310/*
	*/ regist 301-302 llweight 376-380 coweight 381-385/*
	*/ q21_f 141-142 q23_f 145-146 q26a_f 149-150 q26b_f 151-152 q26c_f 153-154/*
	*/ q26d_f 155-156 q26e_f 157-158 q26f_f 159-160 q26g_d 161-162 q26h_f 163-164 q26i_f 165-166/*
	*/ q31_d 191-192 q40_f 197-198 q44_f 211-212/*
	*/ q48a_f 217-218 q48b_f 219-220 q48c_f 221-222 q53_f 223-224 q55_f 227-228/*
	*/ q59_f 237-238 q60_f 239-240 q62_f 243-244 q63_f 245-246 /*
	*/ q67_d 253-254 q68_d 255-256 q69_f 257-258 q70_f 259-260/*
	*/ hispanic 265-266 race 281-282/*
	*/ using Pew/uspew2009-apw.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-apw"

local vars_1 q21_f q23_f q26a_f q26b_f q26c_f q26d_f q26e_f q26f_f q26g_d q26h_f q26i_f q31_d q40_f q44_f q48a_f q48b_f q48c_f q53_f q55_f q60_f q62_f q63_f q68_d q69_f q70_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q59_f q67_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-relig
{
clear
infix 1 lines 1: pollmethod 29 weight 340-344 rid 1-7 sex 273 age 274-275/*
	*/ education 277 party 304 partyln 305 ideology 306/*
	*/ regist 302 llweight 330-334 coweight 335-339/*
	*/ q125_d 65 q146a_d 86 q146b_d 87/*
	*/ hispanic 282 race 288/*
	*/ using Pew/uspew2009-relig.dat

* vote2008
tab pollmethod 
gen survey="uspew2009-relig"

local vars_1 q125_d q146a_d q146b_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2009-values
{
clear
infix 1 lines 1: pollmethod 28 weight 275-279 rid 1-7 sex 220 age 221-222/*
	*/ education 223 party 131 partyln 133 ideology 248/*
	*/ regist 246 llweight 280-284 coweight 285-289/*
	*/ vote2008 136 q13a_d 59 q12_d 80 q13_d 81 q14_d 82/*
	*/ q16_f 84 q17a_f 85 q18a_d 86 q18b_d 87 q18c_d 88/*
	*/ q19a_d 89 q19b_d 90 q19c_d 91 q19bb_d 98 q20b_d 99/*
	*/ q30a_d 139 q30d_d 142 q30e_d 143 q30f_d 144 q30g_d 145/*
	*/ q30k_d 150 q30n_d 153 q30p_f 155 q30u_f 159 q30x_f 161 q30z_d 163/*
	*/ q30cc_d 166 q31g_d 172 q31h_d 173 q31i_d 174 q31j_d 175/*
	*/ q31o_d 178 q31p_d 179 q31gg_d 191 q31hh_d 192/*
	*/ q25b_f 196 q27a_d 198 q27b_d 199 q27c_d 200 q27d_d 201 q27e_d 202/*
	*/ hispanic 227 race 233/*
	*/ using Pew/uspew2009-values.dat

* q13a_d =qa13 | q17a_f = qa17
tab pollmethod 
gen survey="uspew2009-values"

local vars_1 q13a_d q12_d q13_d q14_d q16_f q17a_f q18a_d q18b_d q18c_d q19a_d q19b_d q19c_d q19bb_d q20b_d q30a_d q30d_d q30e_d q30f_d q30g_d q30k_d q30n_d q30p_f q30u_f q30x_f q30z_d q30cc_d q31g_d q31h_d q31i_d q31j_d q31o_d q31p_d q31gg_d q31hh_d q25b_f q27a_d q27b_d q27c_d q27d_d q27e_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-01
{
clear
infix 1 lines 1: pollmethod 13 weight 103-107 rid 1-6 sex 75 age 76-77/*
	*/ education 87 party 79 partyln 80 /*
	*/ q2_f 43/*
	*/ hispanic 89 race 92/*
	*/ using Pew/uspew2010-01.dat

* ideology regist vote2008
* q2_f pewa2
	
tab pollmethod 
gen survey="uspew2010-01"

local vars_1 q2_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 195-199 rid 1-6 sex 137 age 138-139/*
	*/ education 142 party 103 partyln 104 ideology 170/*
	*/ regist 168 vote2008 171 llweight 185-189 coweight 190-194/*
	*/ q36_d 108 q41_d 119 q47_d 122 q48_d 123 /*
	*/ hispanic 147 race 153/*
	*/ using Pew/uspew2010-01pol.dat

tab pollmethod 
gen survey="uspew2010-01pol"

local vars_1 q36_d q41_d q48_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q47_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 195-199 rid 1-6 sex 135 age 136-137/*
	*/ education 140 party 167 partyln 168 ideology 171/*
	*/ regist 165 llweight 185-189 coweight 190-194/*
	*/ q35_d 99 q36_d 100 q37_d 101 q38_d 102 q72_d 126/*
	*/ q73a_d 127 q73b_d 128 q73c_d 129 q73d_d 130/*
	*/ q76_d 132 q77_d 133 q78_d 134/*
	*/ hispanic 144 race 150/*
	*/ using Pew/uspew2010-02pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-02pol"

local vars_1 q36_d q37_d q38_d q72_d q73a_d q73b_d q73c_d q73d_d q76_d q77_d q78_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q35_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-03pol
{
clear
infix 1 lines 1: pollmethod 7 weight 197-204 rid 1-6 sex 131 age 132-133/*
	*/ education 134 party 158 partyln 159 ideology 160/*
	*/ regist 156 llweight 181-188 coweight 189-196/*
	*/ q16_d 74 q26_d 81 q27_d 82 q44_d 103 q52_d 125 q53_d 126/*
	*/ hispanic 136 race 144/*
	*/ using Pew/uspew2010-03pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-03pol"

local vars_1 q16_d q26_d q27_d q44_d q52_d q53_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-04ear
{
clear
infix 1 lines 1: pollmethod 7 weight 76-82 rid 1-6 sex 38 age 40-41/*
	*/ education 52 party 44 partyln 45 ideology 46/*
	*/ q9_d 35 q10_d 36/*
	*/ hispanic 54 race 56/*
	*/ using Pew/uspew2010-04ear.dat

* vote2008 regist

tab pollmethod 
gen survey="uspew2010-04ear"

local vars_2 q9_d q10_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 181-185 rid 1-6 sex 127 age 128-129/*
	*/ education 132 party 158 partyln 159 ideology 160/*
	*/ regist 156/*
	*/ q23_f 63 q30_d 69 q31_d 70/*
	*/ hispanic 137 race 143/*
	*/ using Pew/uspew2010-04pol.dat

* vote2008

tab pollmethod 
gen survey="uspew2010-04pol"

local vars_2 q23_f q30_d q31_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 290-297 rid 1-6 sex 185-186 age 187-188/*
	*/ education 189-190 party 227-228 partyln 229-230 ideology 239-240/*
	*/ regist 223-224 llweight 280-284 coweight 285-289/*
	*/ q42a_d 125-126 q43a_d 129-130 q43b_d 131-132/*
	*/ q50a_d 147-148 q50b_d 149-150 q50c_d 151-152 q50d_d 153-154/*
	*/ q50e_d 155-156 q53_d 157-158 q58_d 161-162 q60_d 165-166 q63_f 171-172/*
	*/ hispanic 191-192 race 207-208/*
	*/ using Pew/uspew2010-06pol.dat

* vote2008

tab pollmethod 
gen survey="uspew2010-06pol"

local vars_1 q42a_d q50a_d q50b_d q50c_d q50d_d q50e_d q53_d q58_d q60_d q63_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q43a_d q43b_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-09pi
{
clear
infix 1 lines 1: pollmethod 7 weight 190-194 rid 1-6 sex 113 age 114-115/*
	*/ education 118 party 94 partyln 96 ideology 143/*
	*/ regist 45 vote2008 144 llweight 180-184 coweight 185-189/*
	*/ q30e_d 71 q30f_d 72 q30g_d 73 q31_d 75 /*
	*/ q38_d 83 q39_d 84 q40_d 85 q46_f 88 q47_f 89/*
	*/ hispanic 122 race 128/*
	*/ using Pew/uspew2010-09pi.dat

tab pollmethod 
gen survey="uspew2010-09pi"

local vars_1 q40_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q30e_d q30f_d q30g_d q31_d q39_d q46_f q47_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

local vars_3 q38_d
foreach var of varlist `vars_3' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 200-204 rid 1-6 sex 128 age 129-130/*
	*/ education 133 party 158 partyln 159 ideology 162/*
	*/ regist 40 vote2008 163 llweight 190-194 coweight 195-199/*
	*/ q48a_d 107 q48b_d 108 q48c_d 109  q48d_d 110/*
	*/ q48e_d 111 q48f_d 112 q73_d 125/*
	*/ hispanic 137 race 143/*
	*/ using Pew/uspew2010-10pol.dat

tab pollmethod 
gen survey="uspew2010-10pol"

local vars_1 q48a_d q48b_d q48c_d q48d_d q48e_d q48f_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q73_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-govtrust
{
clear
infix 1 lines 1: pollmethod 7 weight 227-231 rid 1-6 sex 150 age 151-152/*
	*/ education 155 party 181 partyln 182 ideology 183/*
	*/ regist 179 llweight 217-221 coweight 222-226/*
	*/ q45_d 84 q46_d 86 q67a_d 117 q67d_d 120 q67e_d 121/*
	*/ q68a_d 122 q68b_d 123 q74_d 128/*
	*/ hispanic 159 race 165/*
	*/ using Pew/uspew2010-govtrust.dat

* vote2008 partyln
tab pollmethod 
gen survey="uspew2010-govtrust"

local vars_1 q45_d q46_d q67a_d q67d_d q67e_d q68a_d q68b_d q74_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-relig
{
clear
infix 1 lines 1: pollmethod 7 weight 200-204 rid 1-6 sex 143 age 144-145/*
	*/ education 148 party 169 partyln 170 ideology 171/*
	*/ regist 167 llweight 190-194 coweight 195-199/*
	*/ q12a_d 69 q12b_d 70 q12c_d 71 q12d_d 72 q12e_d 73/*
	*/ q13_d 74 q15a_d 81 q15b_d 82/*
	*/ hispanic 152 race 157/*
	*/ using Pew/uspew2010-relig.dat

* vote2008	
tab pollmethod 
gen survey="uspew2010-relig"

local vars_1 q12a_d q12b_d q12c_d q12d_d q12e_d q13_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q15a_d q15b_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2010-wk0506
{
clear
infix 1 lines 1: pollmethod 7 weight 77-81 rid 1-6 sex 56 age 57-58/*
	*/ education 64 party 62 partyln 63 /*
	*/ regist 61 /*
	*/ q2a_d 24 q2b_d 25 q2c_d 26 q2d_d 27/*
	*/ q10a_d 44 q10b_d 45 q10c_d 46 q11_d 47/*
	*/ hispanic 67 race 69/*
	*/ using Pew/uspew2010-wk0506.dat

* vote2008 ideology
recode regist (1=1) (2=1) (3=2) (9=9)
tab pollmethod 
gen survey="uspew2010-wk0506"

local vars_1 q2a_d q2b_d q2c_d q2d_d q10a_d q10b_d q10c_d q11_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 178-182 rid 1-6 sex 122 age 123-124/*
	*/ education 125 party 142 partyln 143 ideology 144/*
	*/ regist 140 llweight 168-172 coweight 173-177/*
	*/ q21_f 79 q36_f 111 q39a_f 114 q39b_f 115 q39c_f 116 q39d_f 117/*
	*/ hispanic 126 race 132/*
	*/ using Pew/uspew2011-01pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-01pol"

local vars_1 q36_f q39a_f q39b_f q39c_f q39d_f 
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q21_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 161-165 rid 1-6 sex 108 age 109-110/*
	*/ education 111 party 127 partyln 128 ideology 129/*
	*/ regist 125 llweight 151-155 coweight 156-160/*
	*/ q17a_d 55 q17b_d 56 q17c_f 57 q17d_d 58 q17e_d 59/*
	*/ q17f_d 60 q17g_d 61 q17h_d 62 q17i_d 63 q17j_d 64/*
	*/ q17k_f 65 q17l_d 66 q17m_d 67 q17n_d 68 q17o_d 69/*
	*/ q17p_d 70 q17q_f 71 q17s_d 72 q18_d 73/*
	*/ q40_d 83 q41a_d 84 q41b_d 85 q41c_d 86 q41d_d 87/* //neither as a valid response - q40
	*/ q41e_d 88 q41f_d 89 q41g_d 90 q41h_d 91 q55_d 95/*
	*/ q56_d 96 q67_d 103 q69_d 104 q73_d 106/*
	*/ hispanic 112 race 118/*
	*/ using Pew/uspew2011-02pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-02pol"

local vars_1 q17a_d q17b_d q17c_f q17d_d q17e_d q17f_d q17g_d q17h_d q17i_d q17j_d q17k_f q17l_d q17m_d q17n_d q17o_d q17p_d q17q_f q17s_d q18_d q40_d q41a_d q41b_d q41c_d q41d_d q41e_d q41f_d q41g_d q41h_d q69_d q73_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q55_d q56_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

local vars_3 q67_d
foreach var of varlist `vars_3' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 150-154 rid 1-6 sex 103 age 104-105/*
	*/ education 106 party 123 partyln 124 ideology 125/*
	*/ regist 121 llweight 140-144 coweight 145-149/*
	*/ q7_f 54 q9_f 56 q46a_f 75 q46b_f 76 q46c_f 77/*
	*/ q46d_f 78 q46e_f 79 q58_f 95/*
	*/ hispanic 107 race 113/*
	*/ using Pew/uspew2011-04pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-04pol"

local vars_1 q7_f q9_f q46a_f q46b_f q46c_f q46d_f q46e_f q58_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-05pol
{
clear
infix 1 lines 1: pollmethod 7 weight 179-183 rid 1-6 sex 130 age 131-132/*
	*/ education 133 party 151 partyln 152 ideology 153/*
	*/ regist 149 llweight 169-173 coweight 174-178/*
	*/ q37a_d 95 q37b_d 96 q37c_d 97 q37d_d 98 /*
	*/ q37f_d 99 q37g_d 100 q37h_d 101 q37j_d 102/*
	*/ q37k_d 103 q37l_d 104 q37m_d 105 q37n_d 106/*
	*/ q45_f 114/*
	*/ hispanic 134 race 140/*
	*/ using Pew/uspew2011-05pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-05pol"

local vars_1 q37a_d q37b_d q37c_d q37d_d q37f_d q37g_d q37h_d  q37j_d q37k_d q37l_d q37m_d q37n_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q45_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 165-169 rid 1-6 sex 118 age 119-120/*
	*/ education 121 party 138 partyln 139 ideology 140/*
	*/ regist 136 llweight 155-159 coweight 160-164/*
	*/ q18_f 59 q31_d 61 q56_d 93 q57_d 94 q72_f 99/*
	*/ q75_f 102 q79_d 105/*
	*/ hispanic 122 race 128/*
	*/ using Pew/uspew2011-06pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-06pol"

local vars_1 q18_f q31_d q72_f q75_f q79_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q56_d q57_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 204-208 rid 1-6 sex 156 age 157-158/*
	*/ education 159 party 176 partyln 177 ideology 178/*
	*/ regist 174 llweight 194-198 coweight 199-203/*
	*/ q24_d 84 /*
	*/ hispanic 160 race 166/*
	*/ using Pew/uspew2011-07pol.dat

* vote2008 
tab pollmethod 
gen survey="uspew2011-07pol"

local vars_1 q24_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-08pol
{
clear
infix 1 lines 1: pollmethod 7 weight 179-283 rid 1-6 sex 127 age 128-129/*
	*/ education 130 party 148 partyln 149 ideology 152/*
	*/ regist 146 vote2008 154 llweight 174-178 coweight 169-173/*
	*/ q35_d 102 q77a_d 118 q77b_d 119 q77d_d 120 q77e_d 121 q81_f 124/*
	*/ hispanic 131 race 138/*
	*/ using Pew/uspew2011-08pol.dat

tab pollmethod 
gen survey="uspew2011-08pol"

local vars_1 q35_d q77a_d q77b_d q77d_d q77e_d q81_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-09gen
{
clear
infix 1 lines 1: pollmethod 7 weight 173-177 rid 1-6 sex 123 age 124-125/*
	*/ education 126 party 146 partyln 147 ideology 148/*
	*/ regist 144 vote2008 150 llweight 163-167 coweight 168-172/*
	*/ q8_d 48 q69a_d 93 q69b_d 94 q69c_f 95 q70_d 96/*
	*/ q77_d 98 q78_d 99 q79a_d 100 q79b_d 101 q79c_d 102/*
	*/ q80a_d 103 q80b_d 104 q80c_d 105/*
	*/ hispanic 127 race 133/*
	*/ using Pew/uspew2011-09gen.dat

tab pollmethod 
gen survey="uspew2011-09gen"

local vars_1 q69a_d q69b_d q69c_f q70_d q79a_d q79b_d q79c_d q80a_d q80b_d q80c_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}


local vars_2 q8_d q77_d q78_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-11pol
{
clear
infix 1 lines 1: pollmethod 7 weight 201-205 rid 1-6 sex 161 age 162-163/*
	*/ education 164 party 176 partyln 177 ideology 178/*
	*/ regist 58 llweight 191-195 coweight 196-200/*
	*/ q40_d 105 q56_f 123 q58_f 125 q68_d 130 /*
	*/ q71_d 141 q72_d 142 q73_d 143 /*
	*/ hispanic 165 race 172/*
	*/ using Pew/uspew2011-11pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-11pol"

local vars_1 q40_d q56_f q58_f q68_d q71_d q73_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q72_d 
foreach var of varlist `vars_2' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 121 age 122-123/*
	*/ education 124 party 65 partyln 66 ideology 140/*
	*/ regist 61 llweight 159-163 coweight 154-158/*
	*/ q36a_f 94 q36b_f 95 q36c_d 96 q36d_d 97 q36e_d 98/*
	*/ q44e_d 105 q45_d 106 q49_d 117 q52_d 120/*
	*/ hispanic 125 race 132/*
	*/ using Pew/uspew2011-12pol.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-12pol"

local vars_1 q36a_f q36b_f q36c_d q36d_d q36e_d q45_d q49_d q52_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q44e_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2011-sdt09
{
clear
infix 1 lines 1: pollmethod 7 weight 199-203 rid 1-6 sex 37 age 55-56/*
	*/ education 140 party 155 partyln 156 ideology 157/*
	*/ regist 153 /*
	*/ q31_f 115 q32_f 116 q33_f 117 q34_f 118 q35_f 119/*
	*/ hispanic 141 race 174/*
	*/ using Pew/uspew2011-sdt09.dat

* vote2008	
tab pollmethod 
gen survey="uspew2011-sdt09"

local vars_1 q31_f q32_f q33_f q34_f q35_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-01com
{
clear
infix 1 lines 1: pollmethod 7 weight 185-189 rid 1-6 sex 43 age 141-142/*
	*/ education 143 party 161 partyln 162 ideology 163/*
	*/ regist 97 llweight 175-179 coweight 180-184 /*
	*/ q17a_d 57 q17b_d 58 q17c_d 59 q19_d 62/*
	*/ hispanic 144 race 150/*
	*/ using Pew/uspew2012-01com.dat

recode education (8=7)	
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-01com"

local vars_2 q17a_d q17b_d q17c_d q19_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 212-215 rid 1-6 sex 170 age 171-172/*
	*/ education 173 party 70 partyln 71 ideology 190/*
	*/ regist 68 llweight 201-205 coweight 206-210 /*
	*/ q43_f 145 q65_f 167 q69_f 169/*
	*/ hispanic 174 race 181/*
	*/ using Pew/uspew2012-01pol.dat
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-01pol"

local vars_2 q43_f q65_f q69_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 185-189 rid 1-6 sex 139 age 140-141/*
	*/ education 142 party 159 partyln 160 ideology 162/*
	*/ regist 67 llweight 175-179 coweight 180-184 /*
	*/ q43_d 112 q57_f 120 q60_f 121 q61_f 122 q71_d 137/*
	*/ hispanic 143 race 149/*
	*/ using Pew/uspew2012-02pol.dat

recode education (8=7)	
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-02pol"

local vars_1 q61_f q71_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q43_d q57_f q60_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-03pol
{
clear
infix 1 lines 1: pollmethod 7 weight 184-188 rid 1-6 sex 137 age 138-139/*
	*/ education 140 party 156 partyln 157 ideology 158/*
	*/ regist 67 llweight 169-173 coweight 174-178 /*
	*/ q39_f 99 q42_f 100 q43a_d 101 q43b_d 102 q43c_d 103/*
	*/ q43d_d 104 q43e_d 105 q43f_d 106 q45_d 108 q65_f 127/*
	*/ q66_f 128 q67_f 129 q74_d 134/*
	*/ q75_d 135 q76_d 136/*
	*/ hispanic 141 race 147/*
	*/ using Pew/uspew2012-03pol.dat

recode education (8=7)	
	
* vote2008	
tab pollmethod 
gen survey="uspew2012-03pol"

local vars_1 q39_f q42_f q43a_d q43b_d q43c_d q43d_d q43e_d q43f_d q45_d q65_f q66_f q67_f q74_d q75_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q76_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 216-220 rid 1-6 sex 157 age 158-159/*
	*/ education 160 party 186 partyln 187 ideology 189/*
	*/ regist 64 vote2008 191 llweight 206-210 coweight 211-215 /*
	*/ q54_d 143 q66_d 154 q67_d 155 q68_d 156/*
	*/ hispanic 161 race 175/*
	*/ using Pew/uspew2012-06pol.dat

recode education (8=7)	
		
tab pollmethod 
gen survey="uspew2012-06pol"

local vars_1 q54_d q66_d q68_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_3 q67_d
foreach var of varlist `vars_3' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-09pol
{
clear
infix 1 lines 1: pollmethod 7 weight 251-255 rid 1-6 sex 168 age 169-170/*
	*/ education 171 party 197 partyln 198 ideology 199/*
	*/ regist 51 vote2008 201 llweight 246-250 coweight 241-245 /*
	*/ q39_d 156 q40_d 157 q41_d 158/*
	*/ q49a_d 162 q49b_d 163 q49c_f 164 q49d_d 165 q49e_d 166 q49f_d 167/*
	*/ hispanic 172 race 187/*
	*/ using Pew/uspew2012-09pol.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (9=9)	
* 	
tab pollmethod 
gen survey="uspew2012-09pol"

local vars_1 q39_d q41_d q49a_d q49b_d q49c_f q49d_d q49e_d q49f_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q40_d 
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-10ear
{
clear
infix 1 lines 1: pollmethod 7 weight 198-202 rid 1-6 sex 126 age 127-128/*
	*/ education 129 party 145 partyln 146 ideology 148/*
	*/ regist 49 vote2008 150 llweight 172-176 coweight 177-181 /*
	*/ q35a_d 85 q35b_d 86 q35c_d 87 q35d_d 88/*
	*/ q35f_d 89 q35g_d 90 q35h_d 91 q35i_d 92 q35j_d 93/*
	*/ q35k_d 94 q35m_d 95 q35n_d 96 q39_f 97 q42_f 99/*
	*/ q52_f 101 q56_f 102 q59_f 105 q60_f 106/*
	*/ hispanic 130 race 136/*
	*/ using Pew/uspew2012-10ear.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (9=9)	
* 	
tab pollmethod 
gen survey="uspew2012-10ear"

local vars_1 q35a_d q35b_d q35c_d q35d_d q35f_d q35g_d q35h_d q35i_d q35j_d q35k_d q35m_d q35n_d q39_f q42_f q56_f q59_f q60_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q52_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-10late
{
clear
infix 1 lines 1: pollmethod 7 weight 286-290 rid 1-6 sex 141 age 142-143/*
	*/ education 144 party 171 partyln 172 ideology 173/*
	*/ regist 49 vote2008 174 llweight 271-275 coweight 276-280 /*
	*/ q45_d 131 q46_d 132 q55_d 137/*
	*/ hispanic 145 race 151/*
	*/ using Pew/uspew2012-10late.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
* 	
tab pollmethod 
gen survey="uspew2012-10late"

local vars_1 q45_d q46_d q55_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2012-12gun
{
clear
infix 1 lines 1: pollmethod 7 weight 114-118 rid 1-6 sex 72 age 73-74/*
	*/ education 77 party 87 partyln 88 ideology 89/*
	*/ llweight 104-108 coweight 99-103 /*
	*/ q3_d 52 q7_d 63 q8_d 64/*
	*/ q9a_d 65 q9b_d 66 q9c_d 67 q9d_d 68 q12_d 70/*
	*/ hispanic 79 race 85/*
	*/ using Pew/uspew2012-12gun.dat

* regist vote2008
recode education (8=7)	
* recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2012-12gun"

local vars_1 q3_d q7_d q8_d q9a_d q9b_d q9c_d q9d_d q12_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2012-12pol
{
clear
infix 1 lines 1: pollmethod 9 weight 213-222 rid 1-8 sex 146 age 147-148/*
	*/ education 149 party 169 partyln 170 ideology 171/*
	*/ regist 168 llweight 193-202 coweight 203-212 /*
	*/ q6_d 65 q43_d 102 q47a_d 104 q47b_d 105 q47c_d 106/*
	*/ q47d_d 107 q47e_d 108 q47f_d 109 q47g_d 110 q47h_d 111/*
	*/ q47i_d 112 q47j_d 113 q47k_d 114 q47l_d 115 q60_f 120/*
	*/ q65_f 122 q66_f 123/*
	*/ hispanic 150 race 162-163/*
	*/ using Pew/uspew2012-12pol.dat

*  vote2008
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2012-12pol"

local vars_1 q6_d q43_d q47a_d q47b_d q47c_d q47d_d q47e_d q47f_d q47g_d q47h_d q47i_d q47j_d q47k_d q47l_d q65_f q66_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q60_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2012-relig
{
clear
infix 1 lines 1: pollmethod 7 weight 208-212 rid 1-6 sex 155 age 156-157/*
	*/ education 158 party 173 partyln 174 ideology 176/*
	*/ reg 64 regist 63 llweight 198-202 coweight 193-197 /*
	*/ q24_f 99 q26_d 101 q30a_d 102 q30b_d 103/*
	*/ hispanic 159 race 167/*
	*/ using Pew/uspew2012-relig.dat

*  vote2008
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
replace regist=reg if missing(regist)
drop reg
	
tab pollmethod 
gen survey="uspew2012-relig"

local vars_1 q24_f q26_d q30a_d q30b_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2008 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2012-sdt12
{
clear
infix 1 lines 1: pollmethod 7 weight 201-205 rid 1-6 sex 46 age 58-59/*
	*/ education 135 party 155 partyln 156 ideology 157/*
	*/ regist 152 vote2012 153 /*
	*/ q31_d 99 q34a_d 102 q34b_d 103 q34c_d 104/*
	*/ q35a_d 105 q35b_d 106/*
	*/ hispanic 136 race 170/*
	*/ using Pew/uspew2012-sdt12.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2012-sdt12"

local vars_1 q34a_d q34b_d q34c_d q35a_d q35b_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q31_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2012-values
{
clear
infix 1 lines 1: pollmethod 28 weight 300-304 rid 1-6 sex 247 age 248-249/*
	*/ education 250 party 147 partyln 149 ideology 152/*
	*/ reg 61 regist 60 /*
	*/ q18_f 112 q20_d 114 q21_d 115 q30i_d 125 q30j_d 126 q30l_d 128/*
	*/ q30o_d 131 q30v_d 138 q30bb_d 143 q40a_d 177 q40d_d 180/*
	*/ q40e_d 181 q40f_d 182 q40g_d 183 q40k_d 187 q40l_d 188/*
	*/ q40n_d 190 q40o_f 191 q40p_f 192 q40u_f 196 q40x_d 198/*
	*/ q40z_d 199 q40aa_d 200 q40ee_d 201 q41e_d 206 q41f_d 207/*
	*/ q41g_d 208 q41h_d 209 q41i_d 210 q41j_d 211 q41o_d 214/*
	*/ q41p_d 215 q41gg_d 224 q41hh_d 225/*
	*/ hispanic 251 race 261/*
	*/ using Pew/uspew2012-values.dat

* q30v_d = q30v1	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
replace regist=reg if missing(regist)
drop reg
	
tab pollmethod 
gen survey="uspew2012-values"

local vars_1 q18_f q20_d q21_d q30i_d q30j_d q30l_d q30o_d q30v_d q30bb_d q40a_d  q40d_d q40e_d q40f_d q40g_d q40k_d q40l_d q40n_d q40o_f q40p_f q40u_f q40x_d q40z_d q40aa_d q40ee_d q41e_d q41f_d q41g_d q41h_d q41i_d q41j_d q41o_d q41p_d q41gg_d q41hh_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2013-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 189-193 rid 1-6 sex 134 age 135-136/*
	*/ education 139 party 159 partyln 160 ideology 161/*
	*/ regist 158 llweight 179-183 coweight 174-178/*
	*/ q40_d 115 q42a_d 117 q42b_d 118 q42c_d 119 q42d_d 120/*
	*/ q42e_d 121 q42f_d 122 q42g_d 123 q42h_d 124 q42i_d 125 q53_d 132/*
	*/ hispanic 141 race 147/*
	*/ using Pew/uspew2013-01pol.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-01pol"

local vars_1 q40_d q42a_d q42b_d q42c_d q42d_d q42e_d q42f_d q42g_d q42h_d q42i_d q53_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2013-02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 220-224 rid 1-6 sex 168 age 169-170/*
	*/ education 173 party 188 partyln 189 ideology 191/*
	*/ regist 187 llweight 210-214 coweight 205-209/*
	*/ q15_d 70 q17_d 72 q18a_d 73 q18b_d 74 q19_d 75/*
	*/ q20a_d 76 q20b_d 77 q20c_d 78 q23_d 85/*
	*/ q28a_d 86 q28b_d 87 q28c_f 88 q28d_d 89 q28e_d 90/*
	*/ q28f_f 91 q28g_d 92 q28h_d 93 q28i_d 94 q28j_d 95/*
	*/ q28k_f 96 q28l_d 97 q28m_d 98 q28n_d 99 q28o_d 100/*
	*/ q28p_d 101 q28q_f 102 q28r_d 103 q28s_d 104/*
	*/ hispanic 175 race 181/*
	*/ using Pew/uspew2013-02pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-02pol"

local vars_1 q18a_d q18b_d q19_d q20a_d q20b_d q20c_d q23_d q28a_d q28b_d q28c_f q28d_d q28e_d q28f_f q28g_d q28h_d q28i_d q28j_d q28k_f q28l_d q28m_d q28n_d q28o_d q28p_d q28q_f q28r_d q28s_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q17_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

local vars_3 q15_d
foreach var of varlist `vars_3' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2013-03pol
{
clear
infix 1 lines 1: pollmethod 9 weight 201-210 rid 1-8 sex 163 age 164-165/*
	*/ education 166 party 188 partyln 189 ideology 190/*
	*/ regist 187 llweight 211-220 coweight 221-230/*
	*/ q6_d 73 q7_d 74 q15a_d 75 q15b_d 76 q15c_d 77 q15e_d 78/*
	*/ q56_d 113 q61_d 115 q70_f 130 q73_f 132 q77a_d 133 q77b_d 134/*
	*/ q85_d 135 q89_d 140 /*
	*/ hispanic 167 race 178-179/*
	*/ using Pew/uspew2013-03pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-03pol"

local vars_1 q56_d q61_d q77a_d q77b_d q85_d q89_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q6_d q7_d q15a_d q15b_d q15c_d q15e_d q70_f q73_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2013-05pol
{
clear
infix 1 lines 1: pollmethod 7 weight 214-218 rid 1-6 sex 150 age 151-152/*
	*/ education 155 party 182 partyln 183 ideology 184/*
	*/ regist 181 llweight 204-208 coweight 199-203/*
	*/ q17a_d 78 q17b_d 79 q25_d 87 q27_d 89 q36a_d 92 q36b_d 93/*
	*/ q40_d 98 q46a_d 101 q46b_d 102 q46c_d 103 q46d_d 104/*
	*/ hispanic 157 race 163/*
	*/ using Pew/uspew2013-05pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-05pol"

local vars_1 q25_d q27_d q36a_d q36b_d q40_d q46a_d q46b_d q46c_d q46d_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q17a_d q17b_d 
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}

*** uspew2013-06pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 115 age 116-117/*
	*/ education 120 party 134 partyln 135 ideology 136/*
	*/ regist 133 llweight 154-158 coweight 149-153/*
	*/ q15_f 66 q16a_f 67 q16b_f 68 q16c_f 69 q16d_f 70 q37_d 82 q46_d 90/*
	*/ q47b_d 91 q47c_d 92 q47d_d 93 q48_d 94 /*
	*/ q55a_d 98 q55b_d 99 q55c_d 100 q55d_d 101 q55e_d 102 q55f_d 103 q55g_d 104/*
	*/ q56_d 105/*
	*/ hispanic 122 race 129/*
	*/ using Pew/uspew2013-06pol.dat

	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-06pol"

local vars_1 q15_f q16a_f q16b_f q16c_f q16d_f q37_d q46_d q47b_d q47c_d q47d_d q48_d q55a_d q55b_d q55c_d q55d_d q55e_d q55f_d q55g_d q56_d 
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 194-198 rid 1-6 sex 146 age 147-148/*
	*/ education 151 party 115 partyln 116 ideology 169/*
	*/ regist 168 vote2012 171 llweight 189-193 coweight 184-188/*
	*/ q10_d 58 q21_d 70 q40_d 85/*
	*/ hispanic 153 race 160/*
	*/ using Pew/uspew2013-07pol.dat

recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
	
tab pollmethod 
gen survey="uspew2013-07pol"

local vars_1 q21_d q40_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}
local vars_2 q10_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-09pol
{
clear
infix 1 lines 1: pollmethod 7 weight 169-173 rid 1-6 sex 116 age 117-118/*
	*/ education 121 party 139 partyln 140 ideology 141/*
	*/ regist 138 llweight 159-163 coweight 154-158/*
	*/ q5_f 53 q8a_f 58 q8b_f 59 q8c_f 60 q8d_f 61 q8e_f 62 q8f_f 63/*
	*/ q10_d 64 q15_d 65 q41_d 81 q55a_d 92 q55b_d 93/*
	*/ q55c_d 94 q55e_d 95 q55f_d 96 q56a_d 97 q56b_d 98 q56c_d 99/*
	*/ q65_d 105/*
	*/ hispanic 123 race 130/*
	*/ using Pew/uspew2013-09pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
recode q65_d (3 9=.)
tab pollmethod 
gen survey="uspew2013-09pol"

local vars_1 q5_f q8a_f q8b_f q8c_f q8d_f q8e_f q8f_f q41_d q55a_d q55b_d q55c_d q55e_d q55f_d q56a_d q56b_d q56c_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}
local vars_2 q10_d q15_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 198-207 rid 1-6 sex 127 age 128-129/*
	*/ education 130 party 152 partyln 153 ideology 154/*
	*/ regist 151 llweight 178-187 coweight 188-197/*
	*/ q36_d 84/*
	*/ hispanic 131 race 142/*
	*/ using Pew/uspew2013-10pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-10pol"

local vars_1 q36_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-11apw
{
clear
infix 1 lines 1: pollmethod 7 weight 214-218 rid 1-6 sex 162 age 163-164/*
	*/ education 167 party 186 partyln 187 ideology 188/*
	*/ regist 185 llweight 209-213 coweight 204-208/*
	*/ q17_d 96 q20_d 103 q24_f 105 q26_f 107 q28_f 108 q31_f 116/*
	*/ q32a_f 117 q32b_f 118 q32c_f 119 q32d_f 120/*
	*/ q32e_f 121 q32f_f 122 q32i_f 123 q32j_f 124/*
	*/ q33a_f 125 q33b_f 126 q33c_f 127 q33d_f 128 q33e_f 129 /*
	*/ q33f_f 130 q33g_f 131 q33h_f 132 q33i_f 133 q33j_f 134 q33k_f 135/*
	*/ q34_f 136 q40_f 137 q41_f 138 q42_f 139 q43_f 140 q44_f 141 q46_f 142/*
	*/ q49a_d 145 q49c_d 146 q49d_d 147 q49e_d 148 q49f_d 149/*
	*/ q50_f 150 q51_f 151 q52_f 152 q57_d 157/*
	*/ hispanic 169 race 175/*
	*/ using Pew/uspew2013-11apw.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-11apw"

local vars_1 q17_d q24_f q26_f q28_f q32a_f q32b_f q32c_f q32d_f q32e_f q32f_f q32i_f q32j_f q33a_f q33b_f q33c_f q33d_f q33e_f q33f_f q33g_f q33h_f q33i_f q33j_f q33k_f q34_f q40_f q41_f q42_f q43_f q44_f q46_f q49a_d q49c_d q49d_d q49e_d q49f_d q50_f q51_f q52_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q20_d q31_f q57_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 219-223 rid 1-6 sex 156 age 157-158/*
	*/ education 161 party 181 partyln 182 ideology 190/*
	*/ regist 180 llweight 209-213 coweight 204-208/*
	*/ q31_d 75 q33_d 76 q34_d 77 q35_d 78 q36_d 79 q68_f 98/*
	*/ q70b_d 101 q70c_d 102 q70e_f 104 /*
	*/ hispanic 163 race 169/*
	*/ using Pew/uspew2013-12pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-12pol"

local vars_1 q31_d q33_d q68_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q34_d q35_d q36_d q70b_d q70c_d q70e_f 
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0124
{
clear
infix 1 lines 1: pollmethod 7 weight 52-56 rid 1-6 sex 37 age 38-39/*
	*/ education 41 party 50 partyln 51/*
	*/ regist 49 /*
	*/ q1_d 26/*
	*/ hispanic 43 race 45/*
	*/ using Pew/uspew2013-wk0124.dat

* q1_d = pewwp1	
* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0124"

local vars_1 q1_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0207
{
clear
infix 1 lines 1: pollmethod 7 weight 49-53 rid 1-6 sex 34 age 35-36/*
	*/ education 38 party 47 partyln 48/*
	*/ regist 46 /*
	*/ q9_f 23 /*
	*/ hispanic 40 race 42/*
	*/ using Pew/uspew2013-wk0207.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0207"

local vars_1 q9_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0314
{
clear
infix 1 lines 1: pollmethod 7 weight 56-60 rid 1-6 sex 41 age 42-43/*
	*/ education 45 party 54 partyln 55/*
	*/ regist 53 /*
	*/ q9_f 31 /*
	*/ hispanic 47 race 49/*
	*/ using Pew/uspew2013-wk0314.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0314"

local vars_1 q9_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0606
{
clear
infix 1 lines 1: pollmethod 7 weight 81-85 rid 1-6 sex 66 age 67-68/*
	*/ education 70 party 79 partyln 80/*
	*/ regist 78 /*
	*/ q3_d 49 q4_d 56 /*
	*/ hispanic 72 race 74/*
	*/ using Pew/uspew2013-wk0606.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0606"

local vars_2 q3_d q4_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0829
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 43 party 52 partyln 53/*
	*/ regist 51 /*
	*/ q2_f 26 q6_f 31/*
	*/ hispanic 45 race 47/*
	*/ using Pew/uspew2013-wk0829.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0829"

local vars_1 q6_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q2_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk0912
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 42 party 49 partyln 50/*
	*/ regist 48 /*
	*/ q4_f 30/*
	*/ hispanic 43 race 53/*
	*/ using Pew/uspew2013-wk0912.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk0912"

local vars_1 q4_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk1003
{
clear
infix 1 lines 1: pollmethod 7 weight 58-62 rid 1-6 sex 41 age 42-43/*
	*/ education 44 party 51 partyln 52/*
	*/ regist 50 ideology 53/*
	*/ q18_d 33/*
	*/ hispanic 45 race 57/*
	*/ using Pew/uspew2013-wk1003.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk1003"

local vars_1 q18_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2013-wk1031
{
clear
infix 1 lines 1: pollmethod 7 weight 54-58 rid 1-6 sex 39 age 40-41/*
	*/ education 42 party 49 partyln 50/*
	*/ regist 48 /*
	*/ q2a_f 23 q2b_f 24 q2c_f 25 q2d_f 26 q2e_d 27 q7_f 32/*
	*/ hispanic 43 race 53/*
	*/ using Pew/uspew2013-wk1031.dat

* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2013-wk1031"

local vars_1 q2a_f q2b_f q2c_f q2d_f q2e_d q7_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014_02pol
{
clear
infix 1 lines 1: pollmethod 7 weight 184-188 rid 1-6 sex 141 age 65-66/*
	*/ education 142 party 156 partyln 157/*
	*/ regist 155 ideology 158 llweight 174-178 coweight 179-183/*
	*/ q24_d 73 q30_d 75 q39_d 79/*
	*/ hispanic 143 race 150/*
	*/ using Pew/uspew2014_02pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014_02pol"

local vars_1 q24_d q30_d q39_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 234-238 rid 1-6 sex 167 age 168-169/*
	*/ education 170 party 190 partyln 191/*
	*/ regist 189 ideology 199 llweight 219-223 coweight 214-218/*
	*/ q27_d 102 q30_d 105 q35_f 119 q37_f 121 q44b_d 126/*
	*/ q44c_d 127 q44d_d 128 q46a_d 151 q46b_d 152/*
	*/ hispanic 171 race 178/*
	*/ using Pew/uspew2014-01pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-01pol"

local vars_1 q27_d q30_d q35_f q37_f q46a_d q46b_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q44b_d q44c_d q44d_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-04pol
{
clear
infix 1 lines 1: pollmethod 7 weight 181-185 rid 1-6 sex 135 age 136-137/*
	*/ education 138 party 156 partyln 157/*
	*/ regist 155 ideology 158 llweight 171-175 coweight 176-180/*
	*/ q50_f 111 q77a_f 132 q77b_f 133/*
	*/ hispanic 139 race 145/*
	*/ using Pew/uspew2014-04pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-04pol"

local vars_1 q77a_f q77b_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q50_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-07pol
{
clear
infix 1 lines 1: pollmethod 7 weight 168-172 rid 1-6 sex 118 age 119-120/*
	*/ education 121 party 136 partyln 137/*
	*/ regist 135 ideology 140 llweight 158-162 coweight 163-167/*
	*/ q53_f 98 q55_d 100 q60_f 103/*
	*/ hispanic 122 race 155/*
	*/ using Pew/uspew2014-07pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-07pol"

local vars_1 q55_d q60_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q53_f 
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-08pol
{
clear
infix 1 lines 1: pollmethod 7 weight 182-191 rid 1-6 sex 123 age 124-125/*
	*/ education 126 party 150 partyln 151/*
	*/ regist 149 ideology 154 llweight 162-171 coweight 172-181/*
	*/ q52_f 95 q54a_f 96 q54b_f 97 q54c_f 98 q54d_f 99 q54e_f 100/*
	*/ q54f_f 101 q54g_f 102 q54h_f 103 q54i_f 104 q60a_f 105/*
	*/ q60b_f 106 q66_d 109/*
	*/ q69a_d 110 q69b_d 111 q69c_d 112 q70_d 113/*
	*/ hispanic 127 race 138/*
	*/ using Pew/uspew2014-08pol.dat

*  vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-08pol"

local vars_1 q52_f q54a_f q54b_f q54c_f q54d_f q54e_f q54f_f q54g_f q54h_f q54i_f q60a_f q60b_f q69a_d q69b_d q69c_d q70_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q66_d
foreach var of varlist `vars_2' {
recode `var' (4/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-09rel
{
clear
infix 1 lines 1: pollmethod 7 weight 202-206 rid 1-6 sex 105 age 106-107/*
	*/ education 108 party 130 partyln 131/*
	*/ regist 129 ideology 132 vote2012 150 llweight 192-196 coweight 197-201/*
	*/ q14_d 72 q16_d 74 q18_d 75 q19_d 76/*
	*/ hispanic 109 race 116/*
	*/ using Pew/uspew2014-09rel.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-09rel"

local vars_1 q18_d q19_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q14_d q16_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-10pol
{
clear
infix 1 lines 1: pollmethod 7 weight 204-208 rid 1-6 sex 136 age 137-138/*
	*/ education 139 party 155 partyln 156/*
	*/ regist 54 ideology 157 vote2012 159 llweight 194-198 coweight 199-203/*
	*/ q70_d 121 q72_d 123 q75_f 125 q77_f 127/*
	*/ q79_f 129 q80_f 130 q87_f 135/*
	*/ hispanic 140 race 146/*
	*/ using Pew/uspew2014-10pol.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-10pol"

local vars_1 q70_d q72_d q75_f q79_f q80_f q87_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q77_f
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-11post
{
clear
infix 1 lines 1: pollmethod 7 weight 151-155 rid 1-6 sex 107 age 108-109/*
	*/ education 110 party 127 partyln 128/*
	*/ regist 53 ideology 131 llweight 141-145 coweight 146-150/*
	*/ q38_d 81 q69a_f 103 q69b_f 104 q69c_f 105/*
	*/ hispanic 111 race 117/*
	*/ using Pew/uspew2014-11post.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-11post"

local vars_1 q38_d q69a_f q69a_f q69b_f q69c_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-12pol
{
clear
infix 1 lines 1: pollmethod 7 weight 164-168 rid 1-6 sex 120 age 121-122/*
	*/ education 123 party 142 partyln 143/*
	*/ regist 141 ideology 144 llweight 154-158 coweight 159-163/*
	*/ q53_d 87 q70_d 96/*
	*/ hispanic 124 race 130/*
	*/ using Pew/uspew2014-12pol.dat

* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-12pol"

local vars_1 q53_d q70_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace
}
*** uspew2014-typo
{
clear
infix 1 lines 1: pollmethod 12 weight 323-330 rid 1-6 sex 221 age 222-223/*
	*/ education 224 party 249 partyln 250 ideology 255 /*
	*/ regist 248 vote2012 266 llweight 294-303 coweight 304-313/*
	*/ q25b_d 88 q25c_d 89 q25d_d 90 q25f_d 91 q25g_d 92/*
	*/ q25i_f 94 q25m_d 98 q25n_d 99/*
	*/ q50q_d 146 q50r_d 147 q50u_d 150 q50v_d 151 q50bb_f 156/*
	*/ q50dd_d 157 q50ee_f 158 q50ff_d 159 q50gg_d 160 q50hh_d 161/*
	*/ q51ii_d 162 q51kk_d 164 q51ll_d 165 q51oo_d 167 /*
	*/ q106_d 183 q107_d 185 q108_d 186 q110_d 188 q115_f 191/*
	*/ q121_d 195 q122_d 198 q123_d 201 q124_d 204 q125_d 207/*
	*/ q126_d 210 q127_d 213 q128_d 214/*
	*/ hispanic 225 race 291/*
	*/ using Pew/uspew2014-typo.dat
	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-typo"

local vars_1 q106_d q108_d q110_d q115_f q121_d q122_d q123_d q124_d q125_d q126_d q127_d q128_d
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q25b_d q25c_d q25d_d q25f_d q25g_d q25i_f q25m_d q25n_d q50q_d q50r_d q50u_d q50v_d q50bb_f q50dd_d q50ee_f q50ff_d q50gg_d q50hh_d q51ii_d q51kk_d q51ll_d q51oo_d q107_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}

*** uspew2014-wk0306
{
clear
infix 1 lines 1: pollmethod 7 weight 54-59 rid 1-6 sex 33 age 34-35/*
	*/ education 36 party 41 partyln 42 /*
	*/ regist 27 /*
	*/ q5_f 23 q8_f 24/*
	*/ hispanic 37 race 53/*
	*/ using Pew/uspew2014-wk0306.dat
	
* ideology vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0306"

local vars_1 q5_f q8_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}

*** uspew2014-wk0320
{
clear
infix 1 lines 1: pollmethod 7 weight 59-64 rid 1-6 sex 43 age 44-45/*
	*/ education 46 party 53 partyln 54 /*
	*/ regist 52 ideology 55/*
	*/ q3_f 32 q4_f 33 q6_f 35/*
	*/ hispanic 47 race 58/*
	*/ using Pew/uspew2014-wk0320.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0320"

local vars_1 q3_f q4_f q6_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}

*** uspew2014-wk0605
{
clear
infix 1 lines 1: pollmethod 7 weight 52-56 rid 1-6 sex 35 age 36-37/*
	*/ education 38 party 45 partyln 46 /*
	*/ regist 44 ideology 47/*
	*/ q6_f 27/*
	*/ hispanic 39 race 51/*
	*/ using Pew/uspew2014-wk0605.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0605"

local vars_1 q6_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}

*** uspew2014-wk0724
{
clear
infix 1 lines 1: pollmethod 7 weight 51-55 rid 1-6 sex 35 age 36-37/*
	*/ education 38 party 45 partyln 46 /*
	*/ regist 44 ideology 47/*
	*/ q4_f 25 q5_f 26 q6_f 27 q7_f 28/*
	*/ hispanic 39 race 50/*
	*/ using Pew/uspew2014-wk0724.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0724"

local vars_1 q4_f q5_f q6_f q7_f
foreach var of varlist `vars_1' {
recode `var' (8/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}

*** uspew2014-wk0814
{
clear
infix 1 lines 1: pollmethod 7 weight 53-57 rid 1-6 sex 37 age 38-39/*
	*/ education 40 party 47 partyln 48 /*
	*/ regist 46 ideology 49/*
	*/ q2_f 25 q3_f 26 q5_f 27 q7_d 29/*
	*/ hispanic 41 race 52/*
	*/ using Pew/uspew2014-wk0814.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2014-wk0814"

local vars_2 q2_f q3_f q5_f q7_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}
*** uspew2015-01pol
{
clear
infix 1 lines 1: pollmethod 7 weight 170-174 rid 1-6 sex 121 age 122-123/*
	*/ education 124 party 141 partyln 142 /*
	*/ regist 140 ideology 145 llweight 160-164 coweight 165-169/*
	*/ q51_f 112 q54_f 113 q63_d 117 q65_d 119 q66_f 120/*
	*/ hispanic 125 race 131/*
	*/ using Pew/uspew2015-01pol.dat
	
* vote2012	
recode education (8=7)	
recode regist (1=1) (2=1) (3=2) (4=3) (9=9)	
tab pollmethod 
gen survey="uspew2015-01pol"

local vars_1 q66_f
foreach var of varlist `vars_1' {
recode `var' (9=.)
}

local vars_2 q51_f q54_f q63_d q65_d
foreach var of varlist `vars_2' {
recode `var' (3/9=.)
}

reshape long q, i(rid) j(question) string
rename q response

* recode vote2012 (1=1) (2=2) (8/9=3)

append using SNR_t.dta
saveold SNR_t.dta, replace	
}
}
********************************

*** Prepare variables
{
clear
use SNR_t.dta, clear
drop if missing(response)
saveold SNR_t.dta, replace	

clear
use SNR_t.dta, clear
recode vote2000 (1/6=1) (7=2) (8/9=3)
gen VOTE=.
replace VOTE=vote2000 if missing(VOTE)
replace VOTE=vote2004 if missing(VOTE)
replace VOTE=vote2008 if missing(VOTE)
replace VOTE=vote2012 if missing(VOTE)
label define vote 1 "1. yes" 2 "2. no" 3 "3. dk"

foreach var of varlist VOTE vote2000 vote2004 vote2008 vote2012{
label values `var' vote
}

label variable VOTE "voted in last presidential election"
label variable vote2000 "voted in 2000 presidential election"
label variable vote2004 "voted in 2004 presidential election"
label variable vote2008 "voted in 2008 presidential election"
label variable vote2012 "voted in 2012 presidential election"
label define age 97 "97 or older" 99 "99. refused"
label values age age
label variable age "respondent age"
label variable rid "respondent unique id per survey"
label define pollmethod 1 "1. landline" 2 "2. cell"
label values pollmethod pollmethod
label variable pollmethod "polling method: landline vs. cell per respondent"
label variable weight "overall weight variable"
label variable sex "respondent sex"
label define sex 1 "1. male" 2 "2. female"
label values sex sex
recode education (8=9)
label define education 1 "1. none/1-8" 2 "2. 9-11 years" 3 "3. high school grad"/*
	*/ 4 "4. business/nursing, etc." 5 "5. some collage" 6 "6. collage grad" /*
	*/ 7 "7. ma /phd/post" 9 "9. dk/refused"
label values education education
label variable education "respondent education"
recode party (3/5=3) (8=9)
label define party 1 "1. Republican" 2 "2. Democrat" 3 "3. Independent/Other" 9 "9. dk"
label values party party
label variable party "respondent party"
recode partyln (7/8=9)
label define partyln 1 "1. Republican" 2 "2. Democrat" 9 "9. Independent/Other/dk"
label values partyln partyln
label variable partyln "respondent lean to party if party=independent/dk"
gen PARTY5=1 if party==1
replace PARTY5=5 if party==2
replace PARTY5=2 if partyln==1 & inrange(party,3,9)
replace PARTY5=4 if partyln==2 & inrange(party,3,9)
replace PARTY5=3 if partyln==9 & inrange(party,3,9)
label define PARTY5 1 "1. Republican" 2 "2. Lean Republican"/*
	*/ 3 "3. Independent/Other/dk" 4 "4. Lean Democrat" 5 "5. Democrat"
label values PARTY5 PARTY5
recode PARTY5 (1/2=1) (3=2) (4/5=3), gen(PARTY3)
label define PARTY3 1 "1. Republican" 2 "2. Independent/Other/dk" 3 "3. Democrat"
label values PARTY3 PARTY3
label variable PARTY5 "five scale party using lean"
label variable PARTY3 "three scale party using lean"
label define regist 1 "1. yes" 2 "2. no" 3 "3. no need to register" 9 "9. dk"
label values regist regist
label variable regist "is respondent a registered voter"
label define ideology 1 "1. very conservative" 2 "2. conservative"/*
	*/ 3 "3. moderate" 4 "4. liberal" 5 "5. very liberal" 9 "9. dk"
label values ideology ideology
label variable ideology "respondent ideology"
label variable llweight "landline weight"
label variable coweight "cell weight"
label define response 1 "1. valid item-response" 0 "0. item non-response"
label values response response
drop sample
recode hispanic (1=1) (2=2) (8/9=9)
label define hispanic 1 "1. hispanic" 2 "2. not hispanic" 9 "9. dk"
label values hispanic hispanic
recode hispanic (1=1) (2/9=0), gen(HISPANIC)
label define race 1 "1. white" 2 "2. black" 3 "3. asian" 4 "4. other/mixed"/*
	*/ 9 "9. dk"
label values race race
recode race (1 3/9=0) (2=1), gen(BLACK)

rename question questionstr
gen field=.
replace field=1 if strmatch(questionstr,"*_d*")
replace field=2 if strmatch(questionstr,"*_f*")
label define field 1 "1. domestic" 2 "2. foreign"
label values field field
label variable field "question field: domestic vs. foreign"

gen question=questionstr
gen subquestion=""
replace subquestion="a" if strmatch(question,"*a_*")
replace subquestion="b" if strmatch(question,"*b_*")
replace subquestion="c" if strmatch(question,"*c_*")
replace subquestion="d" if strmatch(question,"*d_*")
replace subquestion="e" if strmatch(question,"*e_*")
replace subquestion="f" if strmatch(question,"*f_*")
replace subquestion="g" if strmatch(question,"*g_*")
replace subquestion="h" if strmatch(question,"*h_*")
replace subquestion="i" if strmatch(question,"*i_*")
replace subquestion="j" if strmatch(question,"*j_*")
replace subquestion="k" if strmatch(question,"*k_*")
replace subquestion="l" if strmatch(question,"*l_*")
replace subquestion="m" if strmatch(question,"*m_*")
replace subquestion="n" if strmatch(question,"*n_*")
replace subquestion="o" if strmatch(question,"*o_*")
replace subquestion="p" if strmatch(question,"*p_*")
replace subquestion="q" if strmatch(question,"*q_*")
replace subquestion="r" if strmatch(question,"*r_*")
replace subquestion="s" if strmatch(question,"*s_*")
replace subquestion="t" if strmatch(question,"*t_*")
replace subquestion="u" if strmatch(question,"*u_*")
replace subquestion="v" if strmatch(question,"*v_*")
replace subquestion="w" if strmatch(question,"*w_*")
replace subquestion="x" if strmatch(question,"*x_*")
replace subquestion="y" if strmatch(question,"*y_*")
replace subquestion="z" if strmatch(question,"*z_*")
replace subquestion="aa" if strmatch(question,"*aa_*")
replace subquestion="bb" if strmatch(question,"*bb_*")
replace subquestion="cc" if strmatch(question,"*cc_*")
replace subquestion="dd" if strmatch(question,"*dd_*")
replace subquestion="ee" if strmatch(question,"*ee_*")
replace subquestion="ff" if strmatch(question,"*ff_*")
replace subquestion="gg" if strmatch(question,"*gg_*")
replace subquestion="hh" if strmatch(question,"*hh_*")

replace question=subinstr(question,"_d","",.)
replace question=subinstr(question,"_f","",.)
replace question=subinstr(question,"aa","",.)
replace question=subinstr(question,"bb","",.)
replace question=subinstr(question,"cc","",.)
replace question=subinstr(question,"dd","",.)
replace question=subinstr(question,"ee","",.)
replace question=subinstr(question,"ff","",.)
replace question=subinstr(question,"gg","",.)
replace question=subinstr(question,"hh","",.)
replace question=subinstr(question,"a","",.)
replace question=subinstr(question,"b","",.)
replace question=subinstr(question,"c","",.)
replace question=subinstr(question,"d","",.)
replace question=subinstr(question,"e","",.)
replace question=subinstr(question,"f","",.)
replace question=subinstr(question,"g","",.)
replace question=subinstr(question,"h","",.)
replace question=subinstr(question,"i","",.)
replace question=subinstr(question,"j","",.)
replace question=subinstr(question,"k","",.)
replace question=subinstr(question,"l","",.)
replace question=subinstr(question,"m","",.)
replace question=subinstr(question,"n","",.)
replace question=subinstr(question,"o","",.)
replace question=subinstr(question,"p","",.)
replace question=subinstr(question,"q","",.)
replace question=subinstr(question,"r","",.)
replace question=subinstr(question,"s","",.)
replace question=subinstr(question,"t","",.)
replace question=subinstr(question,"u","",.)
replace question=subinstr(question,"v","",.)
replace question=subinstr(question,"w","",.)
replace question=subinstr(question,"x","",.)
replace question=subinstr(question,"y","",.)
replace question=subinstr(question,"z","",.)

destring question, replace
label variable questionstr "full question id from survey - string variable"
label variable question "question number from survey"
label variable subquestion "subquestion number from survey"

replace survey=lower(survey)

saveold SNR_t.dta, replace	

clear
use SNR_t.dta, clear
keep survey questionstr
duplicates drop
gen temp=_n
drop temp
gen id=_n

saveold SNR_id.dta, replace

clear
use SNR_t.dta, clear
merge m:1 survey questionstr using SNR_id.dta
drop _merge
saveold SNR_t.dta, replace	
}

**** Run t-tests & Cohensd
{
set more off
clear
use SNR_t.dta, clear
quietly ttest response if id==1 & PARTY3 !=2, by(PARTY3)
svret r, keep(r(N_1) r(N_2) r(p) r(mu_1) r(mu_2) r(sd_1) r(sd_2) r(t) r(df_t))
gen id=1
saveold SNR_tresults.dta, replace
clear
use SNR_t.dta, clear
quietly esize twosample response if id==1 & PARTY3 !=2, by(PARTY3) cohensd
svret r, keep(r(d) r(lb_d) r(ub_d))
gen id=1
saveold SNR_cohensd.dta, replace

forval x=2/1158 {
clear
use SNR_t.dta, clear
quietly ttest response if id==`x' & PARTY3 !=2, by(PARTY3)
svret r, keep(r(N_1) r(N_2) r(p) r(mu_1) r(mu_2) r(sd_1) r(sd_2) r(t) r(df_t))
gen id=`x'
append using SNR_tresults.dta
saveold SNR_tresults.dta, replace
clear
use SNR_t.dta, clear
quietly esize twosample response if id==`x' & PARTY3 !=2, by(PARTY3) cohensd
svret r, keep(r(d) r(lb_d) r(ub_d))
gen id=`x'
append using SNR_cohensd.dta
saveold SNR_cohensd.dta, replace
}


clear
use SNR_tresults.dta, clear
merge 1:1 id using SNR_cohensd.dta
drop _merge

label variable r_sd_2 "SD Democrats"
label variable r_sd_1 "SD Republicans"
label variable r_p "p value - significance"
label variable r_t "t value"
label variable r_df_t "Degrees of freedom"
label variable r_mu_2 "Mean Democrats"
label variable r_mu_1 "Mean Republicans"
label variable r_N_2 "N Democrats"
label variable r_N_1 "N Republicans"
label variable r_d "Cohen's D - effect size"
label variable r_lb_d "Cohen's D - lower 95% confidence interval"
label variable r_ub_d "Cohen's D - upper 95% confidence interval"

rename r_sd_2 sd_dem
rename r_sd_1 sd_rep
rename r_p p
rename r_t t
rename r_df_t df
rename r_mu_2 mean_dem
rename r_N_2 n_dem
rename r_mu_1 mean_rep
rename r_N_1 n_rep
rename r_d cohensd
rename r_lb_d cohensd_lower
rename r_ub_d cohensd_upper

format p %9.4f
saveold SNR_tresults.dta, replace

clear
use SNR.dta, clear
keep survey questionstr field unit
duplicates drop
merge 1:1 survey questionstr using SNR_id.dta
drop _merge
merge 1:1 id using SNR_tresults.dta
drop _merge

gen year=.
replace year=2004 if strmatch(survey,"*2004*")
replace year=2005 if strmatch(survey,"*2005*")
replace year=2006 if strmatch(survey,"*2006*")
replace year=2007 if strmatch(survey,"*2007*")
replace year=2008 if strmatch(survey,"*2008*")
replace year=2009 if strmatch(survey,"*2009*")
replace year=2010 if strmatch(survey,"*2010*")
replace year=2011 if strmatch(survey,"*2011*")
replace year=2012 if strmatch(survey,"*2012*")
replace year=2013 if strmatch(survey,"*2013*")
replace year=2014 if strmatch(survey,"*2014*")
replace year=2015 if strmatch(survey,"*2015*")

gen elections=0
replace elections=1 if  survey=="USPEW2004-08NII" |/*
	*/  survey=="USPEW2004-09EAR" |  survey=="USPEW2004-09MID" |/*
	*/  survey=="uspew2004-10earpol" |  survey=="USPEW2004-10MIDPOL" |/*
	*/  survey=="USPEW2004-ELECWKND" |  survey=="USPEW2004-TYPO" |/*
	*/  survey=="USPEW2005-01NII" |  survey=="uspew2006-08NII" |/*
	*/  survey=="uspew2006-09nii" |  survey=="uspew2006-12nii" |/*
	*/  survey=="uspew2006-elec" |  survey=="uspew2006-postelec" |/*
	*/  survey=="uspew2006-turnout" |  survey=="uspew2007-01nii" |/*
	*/  survey=="uspew2008-09late" |  survey=="uspew2008-09mid" |/*
	*/  survey=="uspew2008-10late" |  survey=="uspew2008-10mid" |/*
	*/  survey=="uspew2008-11elec" |  survey=="uspew2008-12pol" |/*
	*/  survey=="uspew2009-01pol" |  survey=="uspew2010-09pi" |/*
	*/  survey=="uspew2010-10pol" |  survey=="uspew2011-01pol" |/*
	*/  survey=="uspew2012-09pol" |  survey=="uspew2012-10ear" |/*
	*/  survey=="uspew2012-10late" |  survey=="uspew2012-12gun" |/*
	*/  survey=="uspew2012-12pol" |  survey=="uspew2012-sdt12" |/*
	*/  survey=="uspew2013-01pol" |  survey=="uspew2014-08pol" |/*
	*/  survey=="uspew2014-09rel" |  survey=="uspew2014-10pol" |/*
	*/  survey=="uspew2014-11post" |  survey=="uspew2014-12pol" |/*
	*/  survey=="uspew2014-wk0814" |  survey=="uspew2015-01pol" 
	
saveold SNR_tresults.dta, replace

clear
use SNR_t.dta, clear
gsort survey questionstr -response
keep survey questionstr response
duplicates drop survey questionstr, force
rename response values
label variable values "# of values in question"
saveold SNR_values.dta, replace

clear
use SNR_tresults.dta, clear
merge 1:1 survey questionstr using SNR_values.dta
drop _merge
saveold SNR_tresults.dta, replace

clear
use SNR_tresults.dta, clear
merge 1:1 survey questionstr using questions_pap.dta
drop _merge

recode pap (1 5 15=1) (0 2/4 6/14 16/20=0), gen(ECONOMY)
recode pap (2 12=1) (0/1 3/10 13/20=0), gen(CIVIL_RIGHTS)
recode pap (3 6 13 14=1) (0/2 4/5 7/12 15/20=0), gen(WELFARE)
recode pap (7 8=1) (0/6 9/20=0), gen(ENERGY)
recode pap (9=1) (0/8 10/20=0), gen(IMMIGRATION)
recode pap (16 18 19=1) (0/15 17 20=0), gen(FOREIGN_AFFAIRS)
recode pap (20=1) (0/19=0), gen(GOVERNMENT)
recode pap (0 4 10 17=1) (1/3 5/9 12/16 18/19=0), gen(OTHER)
recode pap (1 5 15=1) (2 12=2) (3 6 13 14=3) (7 8=4) (9=5) (16 18 19=6) (20=7) (0 4 10 17=8), gen(PAP)
label define PAP 1 "economy" 2 "civil rights" 3 "welfare" 4 "energy" 5 "immigration" 6 "foreign affairs" 7 "government" 8 "other"
label values PAP PAP

saveold SNR_tresults.dta, replace

set more off
clear
use SNR_t.dta, clear
quietly oneway response PARTY3 if id==1 & PARTY3 !=2
svret r, keep(r(N) r(df_m) r(df_r) r(F) r(mss) r(rss))
gen id=1
saveold SNR_F.dta, replace

forval x=2/1158 {
clear
use SNR_t.dta, clear
quietly oneway response PARTY3 if id==`x' & PARTY3 !=2
svret r, keep(r(N) r(df_m) r(df_r) r(F))
gen id=`x'
append using SNR_F.dta
saveold SNR_F.dta, replace
}

clear
use SNR_tresults.dta, clear

gen abs_t=abs(t)
label variable abs_t "absolute value of t"
gen abs_cohensd=abs(cohensd)
label variable abs_cohensd "absolute value of Cohen's d"

merge 1:1 id using SNR_F.dta
drop _merge
saveold SNR_tresults.dta, replace
}
*
